Slackbot
12/07/2022, 9:51 AMThomas Broyer
12/07/2022, 10:33 AMtasks.withType(JavaCompile).configureEach {
doFirst {
exec {
executable '/opt/kythe/extractors/javac-wrapper.sh'
args options.allCompilerArgs
environment 'KYTHE_EXTRACT_ONLY', true
}
}
}
(be careful if you use toolchains, you'd have to also set the JAVA_HOME
environment variable)
I think it would be much better as an individual task but that doFirst
should work as a POC.Jendrik Johannes
12/07/2022, 11:58 AMforkOptions.executable
exists.
But I also noticed that it clashes with the newer toolchain integration nowadays.
@Matan Sabag I think adding this fixes the issue:
javaCompiler.convention(null as JavaCompiler?)
Jendrik Johannes
12/07/2022, 11:59 AMAlex Semin
12/07/2022, 1:43 PMexecutable
property stopped being supported.
For compileJava
the property is intended to accept a path to a valid javac
that is a part of a valid JDK installation. In other words, a toolchain was inferred from this path, and then used.
Starting from Gradle 8.0, toolchains become the main and only way of configuring executables for core JVM tasks. Previously, toolchain tool properties such as javaCompiler
were optional/nullable. With Gradle 8.0 a tool (a compiler in this case) will always be present, and setting it to null will lead to errors.Alex Semin
12/07/2022, 1:48 PMMatan Sabag
12/07/2022, 2:05 PMJendrik Johannes
12/07/2022, 4:03 PMJendrik Johannes
12/07/2022, 4:05 PMJendrik Johannes
12/07/2022, 4:07 PMThomas Broyer
12/07/2022, 4:21 PMjavac-wrapper.sh -version
, as called by default by Gradle to determine the Java version of the toolchain, does nothing (possibly fails). One possibility is to change the script to make it work, or ditch the script and do that same in pure Gradle (more or less what I proposed)Jendrik Johannes
12/07/2022, 4:30 PMAlex Semin
12/07/2022, 4:33 PMJendrik Johannes
12/07/2022, 5:23 PMStarting from Gradle 8.0, toolchains become the main and only way of configuring executables for core JVM tasks.
Alex Semin
12/07/2022, 5:54 PMCompileJava.javaCompiler
are not optional anymore, and it’s not possible to set them to null.
Previously, not all core JVM tasks were using toolchains in all cases. With Gradle 8.0 even if you configure executable
or javaHome
, they will resolve into a toolchain.Vampire
12/07/2022, 5:54 PMVampire
12/07/2022, 5:55 PMexecutable
and do javaCompiler.set(provider { null })
to make the executable
be used.Vampire
12/07/2022, 5:55 PMVampire
12/07/2022, 5:56 PMVampire
12/07/2022, 5:56 PMAlex Semin
12/07/2022, 5:58 PMBut didn’t you just said behavior will not change compared to Gradle 7?I was referring to the
executable
setting in the compileJava
task specifically. There, nothing is really changed apart from the fact that javaCompiler
property will be set whatever toolchain is configured via the executable
. Previously, the javaCompiler
would keep having the null
value if you query it.Vampire
12/07/2022, 5:59 PMexecutable
and the javaCompiler
will be calculated from the exectuable
value?Alex Semin
12/07/2022, 6:01 PMCurrently you can set an@Vampire I am not sure I understand what you mean. It should be enough to setand doexecutable
to make thejavaCompiler.set(provider { null })
be used.executable
options.fork = true
and options.forkOptions.executable
, no need to nullify the compiler property. Unless the toolchain is configured on the java
extension as well.Alex Semin
12/07/2022, 6:03 PMOh, so you can setYes, and it will override the toolchain configured on theand theexecutable
will be calculated from thejavaCompiler
value?exectuable
java
extension as well (Starting with Gradle 8.0)Vampire
12/07/2022, 6:03 PMjava
extension
but need a task to use a different executable.
Then you currently need to set the executable
and additionally set the Java tool property to a null
-producing provider otherwise the executable
is ignored.Alex Semin
12/07/2022, 6:04 PMVampire
12/07/2022, 6:04 PMYes, and it will override the toolchain configured on theYou set anextension as well (Starting with Gradle 8.0)java
executable
for one specific task and that will set the toolchain of the whole Java extension? o_O
I don't think I like that change.
Seems the worng way around.Alex Semin
12/07/2022, 6:05 PMYou set anSorry to confuse you. It will override the toolchain for the task. The extension-level toolchain stays untouched. I mean the “override” in a sense of priority of what gets selected for the task in the end.for one specific task and that will set the toolchain of the whole Java extension? o_Oexecutable
Vampire
12/07/2022, 6:07 PMJendrik Johannes
12/07/2022, 7:31 PM