This message was deleted.
# community-support
s
This message was deleted.
c
have always used toolChain for consistency between IDE / CLI / CI builds. IntelliJ will take it from there.
j
What is this "toolChain" you speak of? 🙂 Is that in gradle?
c
In gradle (docs). A typical usage would be something like
Copy code
java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(11))
    }
}
One can also set the JVM vendor (Adoptium, etc) to use if so desired. Note the toolchain JVM version is separate from the JVM used to execute Gradle. For all our Gradle builds, the Gradle JVM is 17 with the toolchain set per-project as required.
j
thanks for the great explanations!
👍 1
Hate to keep buggin', but... if I have
--add-exports
that I need for part of my build, and I'm now using toolchains, I can't seem to use those w/ the
--release
flag. Can I still suppress
--release
or is there something else I need to do to add some exports?
c
shouldn’t be a problem - it’s still the same JavaCompile task / settings, internally the logic figures out which JVM to execute.
--release
may not be required, as the toolchain explicitly sets the JVM version to use.
j
normally, setting
sourceCompatibility
and
targetCompatibility
would suppress
--release
flag, but we can't use those anymore w/ toolchain.
c
they aren’t needed with toolchain - the compatibility stuff is only for when you are using one JVM for multiple things (running Gradle, compiling X, Y, Z, etc) - with toolchain you can separate those concerns.
v
Why should you use
source- / targetCompatibility
if you are using Java toolchains feature? One practially superseeds the other. You configure the toolchain that you would have set for compatibility.
j
we need
--add-exports
. This does not work with
--release
and using toolchains causes
--release
to be used.
I'm saying, previously, the use of
source/targetCompatibility
was suppressing
--release
and allowing
--add-exports
to work.
v
Toolchains should not use
--release
I think. It is not necessary, as the correct Java version is used to execute the compiler, so
--release
would be superfluous, wouldn't it? Besides why should add-exports not work with release?
Unless you set a release <9
In which case
--add-exports
wouldn't make any sense
j
we only add the exports when java version >8. I'll check gradle/IJ are all on 17....
everything says 17
c
are there arguments, such as --release, passed to the JavaCompile task?
j
just
--add-exports
c
ok. can’t recall seeing
--release
being part of the arguments, worth figuring out where that is coming from.
j
ahhh, I think I see it. probably my bad.
c
It’s perhaps this issue: https://github.com/gradle/gradle/issues/18824
j
ahhhhh, I think you are right!
c
there’s a reasonable workaround in there that hopefully with sidestep this.
j
yup. đź’Ż perfect!
tyvm!
v
Hm, strange, it wonder why the release flag is set at all, as the correct jdk is used already. Must have remembered wrongly it seems.
c
yea, was confused as well. it boils down to this Gradle code:
Copy code
if (!isSourceOrTargetConfigured) {
                    JavaLanguageVersion languageVersion = toolchain.getLanguageVersion();
                    if (languageVersion.canCompileOrRun(10)) {
                        spec.setRelease(languageVersion.asInt());
                    } else {
                        String version = languageVersion.toString();
                        spec.setSourceCompatibility(version);
                        spec.setTargetCompatibility(version);
                    }
                }
(JavaCompile.java)
still questionable as to why bother settings release when you have a toolchain…