Add support for specifying the Java toolchain for invoking R8
madisp opened this issue · 8 comments
It would be awesome if this:
- defaulted to the project-wide java toolchain
- one could override if needed
https://docs.gradle.org/current/userguide/toolchains.html#sec:plugins
There's a comment in Gr8Task
as well that this could be helpful -
Good callout 👍 . Any idea what options to expose override this? I guess it should take a path?
gr8 {
javaHome.set("path/to/java/home")
}
ideally should expose setting the toolchain launcher itself, while defaulting to the toolchain
provided by the Java extension by default, check the section "Toolchains for JVM projects" here:
https://docs.gradle.org/current/userguide/toolchains.html#sec:plugins
that way if someone does something like
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
vendor.set(JvmVendorSpec.AZUL)
}
}
you can get that toolchain picked up automatically.
If you have a Property<JavaLauncher>
you can turn it into a java.home
File
with something like:
val javaHome = launcher.get().executablePath.asFile.parentFile.parentFile
Property<JavaLauncher>
Thanks that sounds perfect 👍
Do we want to be able to run R8 using e.g. Java 20 while still passing it Java 11 runtime jars? That'd save launching a new JVM if your main build is using 20. But maybe it's not worth it?
I forked the task (only needed a handy R8 invoke task :)), that's exactly what I'm doing (invoking on Gradle the JVM Gradle is running on) while runtime jars are passed in from the launcher. I guess it would make sense to name it differently or actually use it for launching?
For invoking afaik the Worker APIs had nice facilities to create isolated tasks that run on a different JVM.
invoking on Gradle the JVM Gradle is running on while runtime jars are passed in from the launcher
Nice. I think that's a good default, no need to downgrade the JVM just to get the runtime jars.
I can make a PR for this later in the evening today
Awesome, thanks!
Closed with #16