Tune config of source and target compatilility with toolchain
See gh-26932
This commit is contained in:
		
							parent
							
								
									6e43dd879b
								
							
						
					
					
						commit
						ac8c6a6fb7
					
				| 
						 | 
				
			
			@ -198,17 +198,21 @@ class JavaConventions {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	private void configureJavaConventions(Project project) {
 | 
			
		||||
		JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
 | 
			
		||||
		javaPluginExtension.setSourceCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
 | 
			
		||||
		if (!project.hasProperty("toolchainVersion")) {
 | 
			
		||||
			JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
 | 
			
		||||
			javaPluginExtension.setSourceCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
 | 
			
		||||
		}
 | 
			
		||||
		project.getTasks().withType(JavaCompile.class, (compile) -> {
 | 
			
		||||
			compile.getOptions().setEncoding("UTF-8");
 | 
			
		||||
			compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
 | 
			
		||||
			compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
 | 
			
		||||
			List<String> args = compile.getOptions().getCompilerArgs();
 | 
			
		||||
			if (!args.contains("-parameters")) {
 | 
			
		||||
				args.add("-parameters");
 | 
			
		||||
			}
 | 
			
		||||
			if (!project.hasProperty("toolchainVersion") && JavaVersion.current() == JavaVersion.VERSION_1_8) {
 | 
			
		||||
			if (project.hasProperty("toolchainVersion")) {
 | 
			
		||||
				compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
 | 
			
		||||
				compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
 | 
			
		||||
			}
 | 
			
		||||
			else if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
 | 
			
		||||
				args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
 | 
			
		||||
						"-Xlint:varargs"));
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue