Skip to content

java-version-file with asdf's .tool-versions fails for Corretto, also non-strict semver versions #615

Description

@rtyley

Description:
Support for asdf's .tool-versions file was added to the java-version-file parameter with PR #606 in response to issue #579 - unfortunately, there's a difference between what asdf requires for this file, vs what setup-java supports:

asdf requires that the Java version in .tool-versions is fully specified

So a file will typically look like this:

java corretto-21.0.2.13.1

If you shorten the version, eg to 21.0.2 or 21, and run asdf install java, you'll get this error from asdf:

Unknown release: corretto-21.0.2

setup-java only supports major versions or strict 3-part semver

setup-java supports version numbers of 1 to 3 dot-separated integers (eg major to major.minor.patch). This excludes several valid version numbers - here are some examples:

  • all Corretto version numbers, which are always at least 4-part (eg 21.0.2.13.1 or 8.322.06.4)
  • Zulu 8.74.0.17
  • sapmachine 11.0.16.1
  • Oracle 18.0.2.1
  • Microsoft 17.0.1.12.1

setup-java only supports major versions for Corretto

This is probably due to AWS Corretto only providing a simple API for looking up Java versions, that only supports getting the latest version for each major version of Java:

'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json';

So, Corretto with the java-version-file parameter is doubly unsupported:

  • Corretto 5-part version numbers don't match the regex's used by setup-java to verify version numbers
  • Even if Corretto version numbers were accepted, corretto/installer.ts wouldn't be able to locate and download the specific Corretto version, because it can only support finding by major version number
    if (version.includes('.')) {
    throw new Error('Only major versions are supported');

Task version:

v4.2.1

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
Define an invocation of actions/setup-java in a workflow, and point java-version-file to .tool-versions:

.github/workflows/ci.yml :

        uses: actions/setup-java@v4
        with:
          distribution: zulu
          java-version-file: .tool-versions

In .tool-versions, define a version like zulu-8.58.0.13 - and verify that works by executing asdf install java:

.tool-versions :

java zulu-8.58.0.13

The let the ci.yml workflow run.

Expected behavior:
Ideally, if the .tool-versions file is valid for asdf, setup-java should install that precise version of Java. This means setup-java needs to accept all versions output by asdf list-all java.

Where a distribution has been specified that setup-java is unable to search for precise Java versions (ie Corretto), if the user has set a java-version-accept-any-matching-major-version parameter to true it should just install the latest version of Java for that major version.

Actual behavior:

zulu-8.58.0.13 in .tool-versions (guardian/etag-caching@959d4dc) :
https://github.com/guardian/etag-caching/actions/runs/8470107933/job/23207054598#step:3:16

No supported version was found in file .tool-versions

image

cc @aparnajyothi-y @mahabaleshwars @HarithaVattikuti

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions