This message was deleted.
# community-support
s
This message was deleted.
t
I wouldn't integrate Kythe with Gradle that way (despite that being what the Kythe doc says), it probably worked with older versions of Gradle, but no longer. Something you could try:
Copy code
tasks.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.
j
I don't think the original suggestion is bad. I think that's a case for which
forkOptions.executable
exists. But I also noticed that it clashes with the newer toolchain integration nowadays. @Matan Sabag I think adding this fixes the issue:
Copy code
javaCompiler.convention(null as JavaCompiler?)
a
At some point before Gradle 7.6 passing an arbitrary executable to the
executable
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.
👍 1
@Jendrik Johannes What was the reason you were trying to set the compiler to null?
m
@Thomas Broyer - It seems to work, thanks! I will also give it a try with tool chains and see how it works. @Jendrik Johannes - This didn’t work..not sure why but I get the same error
j
@Alex Semin I just wanted to demonstrate (see the video) that you can set the "executable" as one option to make the JavaCompile task fork a separate process. It did not work without doing this (but maybe that is because I also configured a toolchain).
@Alex Semin If you remove the option of setting an executable completely, there should really be done something here: https://github.com/gradle/gradle/issues/15942#issuecomment-1316817116 Right now, it's the only sane way to use the Eclipse compiler. I think you shut a lot of folks out, if you remove that without replacement. 😕 (As I said already in the Gradle internal Slack to Louis, I am happy to meet about that topic to see if we can help there further)
@Matan Sabag sorry that that didn't help. Wrong guess from my side then.
t
I guess the problem here is that
javac-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)
j
That makes sense. Thanks for the explanation @Thomas Broyer.
a
@Jendrik Johannes The executable option availability and usage in Gradle 8.0 is unchanged compared to Gradle 7
j
Thanks for clarifying. I misunderstood then. Can you elaborate (or link some docs) about what the practical consequences of this are then:
Starting from Gradle 8.0, toolchains become the main and only way of configuring executables for core JVM tasks.
a
@Jendrik Johannes Mainly that toolchain-related properties on the tasks, such as
CompileJava.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.
v
But didn't you just said behavior will not change compared to Gradle 7?
Currently you can set an
executable
and do
javaCompiler.set(provider { null })
to make the
executable
be used.
If that goes away with Gradle 8, also this is a must-have for us to upgrade: https://github.com/gradle/gradle/issues/16245
Otherwise you cannot use a non-detected toolchain that you for example build in the current build run
The toolchain provisioning SPI does not help for that
a
But 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.
v
Oh, so you can set
executable
and the
javaCompiler
will be calculated from the
exectuable
value?
a
Currently you can set an
executable
and do
javaCompiler.set(provider { null })
to make the
executable
be used.
@Vampire I am not sure I understand what you mean. It should be enough to set
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.
Oh, so you can set
executable
and the
javaCompiler
will be calculated from the
exectuable
value?
Yes, and it will override the toolchain configured on the
java
extension as well (Starting with Gradle 8.0)
v
Yes, if you currently have a toolchain in the
java
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.
a
You can find more technical details for this change here: https://github.com/gradle/gradle/pull/22108
v
Yes, and it will override the toolchain configured on the
java
extension as well (Starting with Gradle 8.0)
You set an
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.
a
You set an
executable
for one specific task and that will set the toolchain of the whole Java extension? o_O
Sorry 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.
v
Ah, ok, then it sounds perfect, thanks for the clarification. :-)
j
Thanks for explaining @Alex Semin. Makes sense and sounds like a great unification/simplification in this area.
👍 2