diff --git a/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java b/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java index 8d3d48e298..48b36c92db 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java @@ -202,11 +202,17 @@ class JavaConventions { compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY); compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY); } - args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes", - "-Xlint:varargs")); + else if (buildingWithJava17(project)) { + args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes", + "-Xlint:varargs")); + } }); } + private boolean buildingWithJava17(Project project) { + return !project.hasProperty("toolchainVersion") && JavaVersion.current() == JavaVersion.VERSION_17; + } + private void configureSpringJavaFormat(Project project) { project.getPlugins().apply(SpringJavaFormatPlugin.class); project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8"));