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

Environment variables defined in toolchains.xml are incorrect on ARM runners #89

Closed
hfhbd opened this issue Mar 23, 2024 · 2 comments · Fixed by #150
Closed

Environment variables defined in toolchains.xml are incorrect on ARM runners #89

hfhbd opened this issue Mar 23, 2024 · 2 comments · Fixed by #150
Labels
bug Something isn't working in:setup-gradle
Milestone

Comments

@hfhbd
Copy link
Contributor

hfhbd commented Mar 23, 2024

The toolchain.xml contains x86 env variables which aren't guaranteed to exist on arm, like macOS-14 (M1) or Ubuntu Arm runners (currently in private Beta), or on any custom hosted runner:

<!-- JDK Toolchains installed by default on GitHub-hosted runners -->
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>8</version>
      <vendor>Eclipse Temurin</vendor>
    </provides>
    <configuration>
      <jdkHome>${env.JAVA_HOME_8_X64}</jdkHome>
    </configuration>
  </toolchain>

When using Gradle, this results into these warnings on macOS-14 (M1)/Ubuntu Arm:

Directory '/home/runner/.gradle/daemon/8.7-rc-3/${env.JAVA_HOME_8_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/8.7-rc-3/${env.JAVA_HOME_21_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/8.7-rc-3/${env.JAVA_HOME_11_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/8.7-rc-3/${env.JAVA_HOME_17_X64}' (Maven Toolchains) used for java installations does not exist

After using setup-java with 21, on Ubuntu Arm there is only one env: JAVA_HOME_21_ARM64=/home/runner/work/_tool/Java_Adopt_jdk/21.0.2-13.0.LTS/arm64

@bigdaz
Copy link
Member

bigdaz commented Mar 25, 2024

Thanks for your report. The reason for the hard-coded toolchains.xml file is to ensure that pre-installed JDKs are used when Gradle resolves a Java toolchain. Without this, Gradle will download a JDK even when the same one is already installed on the runner.

To support ARM equally, we need to choose between:

  1. Removing this hard-coded list. Users will need to use setup-java (which adds to toolchains.xml) in order to benefit from pre-installed JDKs.
  2. Add a separate hard-coded toolchains list for ARM.
  3. Add the _arm equivalents to the hard-coded list, and validate against the actual environment, removing any that are unknown.

My preference would be for the 3rd option. Are you interested in submitting a PR for this?

@hfhbd
Copy link
Contributor Author

hfhbd commented Mar 25, 2024

Are you interested in submitting a PR for this?

Yes

@bigdaz bigdaz changed the title toolchain.xml: Support ARM/Drop x86 Environment variables defined in toolchains.xml are incorrect on ARM runners Apr 1, 2024
@bigdaz bigdaz added bug Something isn't working in:setup-gradle labels Apr 5, 2024
bigdaz added a commit that referenced this issue Apr 10, 2024
Different runners have different JDKs installed, so using a hard-coded
list for
`toolchains.xml` doesn't work. With this change, the file is generated
based on the available `JAVA_HOME_*` environment variables.

Fixes #89 

Thanks @hfhbd for the contribution!

Co-authored-by: hfhbd <22521688+hfhbd@users.noreply.github.com>
@bigdaz bigdaz added this to the v3.3 milestone Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in:setup-gradle
Projects
None yet
2 participants