-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provision min runtime version jdk for compilation #105152
Conversation
This commit adjusts compile tasks to explicitly provision a Java toolchain for the Java minimum runtime version. By doing so the Java used by Gradle may be upgraded without the possibility of causing spurious warnings from javac which could fail the build, such as when new warnings are added in later JDK versions.
Pinging @elastic/es-delivery (Team:Delivery) |
@@ -112,6 +123,10 @@ public static void configureCompile(Project project) { | |||
java.setSourceCompatibility(BuildParams.getMinimumRuntimeVersion()); | |||
java.setTargetCompatibility(BuildParams.getMinimumRuntimeVersion()); | |||
project.getTasks().withType(JavaCompile.class).configureEach(compileTask -> { | |||
compileTask.getJavaCompiler().set(javaToolchains.compilerFor(spec -> { | |||
spec.getLanguageVersion().set(JavaLanguageVersion.of(BuildParams.getMinimumRuntimeVersion().getMajorVersion())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we actually use minimumCompilerVersion
? Although, I struggle to see why we have both, and when they would ever be different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was mimicking the source and target compatibility above. It does seem odd that we have both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, on the 7.17 branch, the minimumCompilerVersion
is 17 while minimumRuntimeVersion
is 8. I believe the reason for this is because to keep the build logic consistent across these branches we require Java 17 to build 7.17 even though the production code targets Java 8. In reality it should be minimumGradleJavaVersion
but we can follow up to clean this stuff up.
This commit adjusts compile tasks to explicitly provision a Java toolchain for the Java minimum runtime version. By doing so the Java used by Gradle may be upgraded without the possibility of causing spurious warnings from javac which could fail the build, such as when new warnings are added in later JDK versions.