-
Notifications
You must be signed in to change notification settings - Fork 664
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
Configure target java version alongside gradle toolchain #5676
Conversation
✅ Deploy Preview for nextflow-docs-staging canceled.
|
All green, switch to Ready to review and merge? |
467d81e
to
7b9be79
Compare
Solved by 6dd92e3. Feel free to re-open if it still does not solve your problem. |
That change doesn't seem to have solved it: the I did some digging and there's a few things going on here. The relevant javac compiler options are:
Source/targetin this version of Gradle, the intended way to set java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
sourceCompatibility = 17
targetCompatibility = 17
} I was able to verify that this does seem to work - all the .class files (including those generated from both .groovy and .java files) have the correct version (61). Unlike setting this on the compile tasks explicitly, this also correctly sets the required Java version on the variant jars (like test fixtures). This change would fix the issue described in this PR. ReleaseWhile not needed for this fix, the compileJava {
options.release.set(17)
} This is slightly incorrect because it doesn't apply to the tests, so an improvement would be: tasks.withType(JavaCompile).configureEach {
options.release = 17
} Except of course when compiling with groovyc in 'joint' mode, neither approach has any effect (ie the existing config on master isn't doing anything either). We'd need to specify it on the Groovy compile tasks for it to be applied. Using groovyc directly, it would look like this: groovyc -j -J-release=17 ... Unfortunately, as far as I can tell, there doesn't seem to be a way to persuade Gradle to correctly pass this through in joint compilation mode - In any case, since this already seems not to be working on master, it's probably a separate issue to the change needed for test fixtures. |
1f834a0
to
6454605
Compare
Have you tried using
|
7b9be79
to
48a5b12
Compare
I think the |
Even better then! please add a comment to highlight |
This applies it to all gradle variants (including test fixtures) Signed-off-by: Tom Sellman <tom.sellman@seqera.io>
48a5b12
to
f35da0c
Compare
Configure the target Java version inside the gradle
java
block next to the toolchain info, rather than on a per-task basis. This propogates the information to all the variants, in particular the test fixtures.Without this, a project depending on the test fixtures (such as a nextflow plugin) can, in some situations, fail to build with the following error:
Before this change
Using command

gradle :nextflow:outgoingVariants
to show the variants, the 'main' variants correctly declare that they require Java 17:but the 'testFixtures' variants requires Java 21:

After this change
All the Java variants require Java 17:


All the compiled bytecode still has class file format version 61 (Java 17).