Gradle and Eclipse's Java version

eclipse

(Tom Eugelink) #1

JFXtras version 9 has a Gradle build file with a correctly set sourceCompatibility (=9) but refreshing the project in Eclipse keeps (re)setting it to Java 8. What is the correct way to have Eclipse set the correct JDK when switching between branches (and Java versions)?


(Tom Eugelink) #2

It would also help if the Gradle eclipse plugin would configure the workspace default for both runtime and compiler settings, instead of project specific settings, then I could switch it in one go for all subprojects.


(Tom Eugelink) #3

Maven keeps luring me to switch back.


(Tom Eugelink) #4

I’ve added this to the build, which removes JavaSE-1.8 and adds JavaSE-9, and marks the test source folders as containing tests. This seems so trivial that the eclipse plugin should really handle this.

	// Force Java 9 in Eclipse config
	eclipse {
	   classpath {
	        containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9/'
			file {
	    		whenMerged { classpath ->
	    			classpath.entries.removeAll { entry -> entry.kind == 'con' && !entry.path.contains('JavaSE-9')}
					classpath.entries.findAll{ it.kind == 'src' && it.path.contains('/test/') }.each { 
						it.entryAttributes['test'] = 'true'
					}
				}
	   		}
	   }
	   jdt {
			sourceCompatibility = org.gradle.api.JavaVersion.VERSION_1_9
			targetCompatibility = org.gradle.api.JavaVersion.VERSION_1_9
	   }
	}

(ZOSROTHKO) #5

JDK 1.9 is no more available for downloading. I would suggest to switch to Java-1.10 or Java-1.11

Downloding JDK-1.9


#6

I don’t know if this is the right place to go for this problem, but I’m new to all of this and I’m really confused. I was trying to install Gradle onto my pc (Windows 10), but every time I try and check the status of the installation using the “gradle -v” command in the powershell it comes up with this reply:

gradle : The term ‘gradle’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • gradle -v
  •   + CategoryInfo          : ObjectNotFound: (gradle:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

Blockquote

I’m sure I put in the correct directory for the environment variables. But I am really new to this stuff and I’m not sure on anything. If anyone can, please help me install it correctly.


(ZOSROTHKO) #7

Under a DOS windows, the native command for invoking Gradle is: gradlew -v