Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying the Java toolchain for invoking R8 #9

Closed
madisp opened this issue Mar 21, 2023 · 8 comments
Closed

Add support for specifying the Java toolchain for invoking R8 #9

madisp opened this issue Mar 21, 2023 · 8 comments

Comments

@madisp
Copy link
Contributor

madisp commented Mar 21, 2023

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 -

* We might need an option to override that as if you're running newer versions of Java to run the task

@martinbonnin
Copy link
Member

Good callout 👍 . Any idea what options to expose override this? I guess it should take a path?

gr8 {
  javaHome.set("path/to/java/home")
}

@madisp
Copy link
Contributor Author

madisp commented Mar 22, 2023

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

@martinbonnin
Copy link
Member

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?

@madisp
Copy link
Contributor Author

madisp commented Mar 22, 2023

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.

@martinbonnin
Copy link
Member

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.

@madisp
Copy link
Contributor Author

madisp commented Mar 22, 2023

I can make a PR for this later in the evening today

@martinbonnin
Copy link
Member

Awesome, thanks!

@martinbonnin
Copy link
Member

Closed with #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants