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

Auto detection of installed toolchains for Github Action setup-java #20459

Closed
meiao opened this issue Apr 13, 2022 · 2 comments
Closed

Auto detection of installed toolchains for Github Action setup-java #20459

meiao opened this issue Apr 13, 2022 · 2 comments
Labels
a:feature A new functionality in:toolchains Java Toolchains

Comments

@meiao
Copy link

meiao commented Apr 13, 2022

When running a Java project in Github Actions it is common to use Github's setup-java action to install each version of Java. They are (currently) installed to /opt/hostedtoolcache/jdk/{jdk version}/x64 which is not in the auto detect path for Gradle's toolchain.

So when a build uses toolchains, it will not use the JDK installed by setup-java and will either try to find the required JDKs in the system or download as needed.

Expected Behavior

JDKs installed by setup-java are auto detected.

Current Behavior

Toolchain auto detection does not detect JDKs installed by setup-java.

Context

This affected a project that builds with Java 8 but creates Javadoc with Java 11. Even though we were installing the latest version of 11, the generated Javadoc had a JS resource that was older than the one from 11.0.14.

To investigate why that was happening, I created this repo https://github.com/meiao/expert-octo-toolchain-test/ which has longer description and a workaround.

It would also be nice to have a flag to disable auto detect in places other than the path used by setup-java so this way it would be harder to use an unexpected JDK.

@meiao meiao added a:feature A new functionality to-triage labels Apr 13, 2022
@hegyibalint hegyibalint added in:toolchains Java Toolchains and removed to-triage labels Apr 15, 2022
@tbroyer
Copy link
Contributor

tbroyer commented Oct 2, 2022

Isn't this a duplicate of #14903?

And you can use org.gradle.java.installations.auto-detect and org.gradle.java.installations.paths (or org.gradle.java.installations.fromEnv) properties to control Gradle's behavior: https://docs.gradle.org/current/userguide/toolchains.html

@meiao
Copy link
Author

meiao commented Oct 3, 2022

It is. But in here there is also a nod to using a possibly maliciously installed Java environment.

I've used those parameters, and the linked repo has instructions on how to use those.

Anyway, closing as dupe.

@meiao meiao closed this as completed Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:toolchains Java Toolchains
Projects
None yet
Development

No branches or pull requests

3 participants