This message was deleted.
# community-support
s
This message was deleted.
t
Assuming you want to compile an Error Prone custom check (https://github.com/tbroyer/gradle-errorprone-plugin/issues/93), and looking at how Error Prone itself is compiled (https://github.com/google/error-prone/blob/ae3a19f44e173847d5e01bc95fd0b1d74a41d6b6/pom.xml#L181-L206), you'll want to use those 12 add-exports to your
compilerArgs
, and add the add-opens and add-exports from https://errorprone.info/docs/installation (or https://github.com/google/error-prone/blob/ae3a19f44e173847d5e01bc95fd0b1d74a41d6b6/pom.xml#L235-L257) to the
jvmArgs
of your test and exec tasks.
You can indeed reduce the list (for the
compilerArgs
at least); for instance, the custom check I use in the gradle-errorprone-plugin integration tests has a much smaller list: https://github.com/tbroyer/gradle-errorprone-plugin/blob/5d9e2a80d37fcdb393ff694f1[…]n/net/ltgt/gradle/errorprone/ErrorPronePluginIntegrationTest.kt
m
Thanks Thomas for the quick response, when I try to add-exports, I get this:
error: exporting a package from system module jdk.compiler is not allowed with --release
I have a pretty standard build configuration, is there anything else I shoudl modify?
t
Ah, I think you cannot use toolchains (IIRC), and must use `sourceCompatibility`/`targetCompatibility` (and specifically not
release
) to define Java compatibility.
😪 1
v
Is using toolchain really adding
release
if not explicitly setting it? I'd assumed that due to the proper toolchain being used already,
release
should not be necessary.
m
@Vampire I do use toolchain, this is my only configuration
JavaPluginExtension javaExt = (JavaPluginExtension) project.getExtensions().getByName("java");
javaExt.getToolchain().getLanguageVersion().set(JavaLanguageVersion.of(11));
v
Yeah, just testing also. Seems you even cannot prevent it using
tasks.compileJava { options.release.set(provider { null }) }
😞 You can only override it to something else. So it indeed seems to be not possible to use something that is incompatible with
--release
with toolchains, except with some trickery like
Copy code
tasks.compileJava {
    javaCompiler.set(provider { null })
    options.forkOptions.javaHome = javaToolchains.compilerFor(java.toolchain).get().metadata.installationPath.asFile
}
m
So, @Vampire, should I refrain from using toolchain and use source and target compatability instead?
v
Assuming @Thomas Broyer is correct regarding
-release
being the problem, I would probably use what I posted last + defining compatibility on the task. Then other tasks can continue using the defined toolchain and also the computer task is using the toolchain, just in a custom way, so you preserve the separation of Java to run Gradle and the Java to build your project. It might also be worth submitting a bug or feature request for being able to not use
-release
with normal toolchain usage, as you have a valid use-case for it.