Skip to content

Infer distribution from asdf .tool-versions vendor prefix#1084

Merged
brunoborges merged 3 commits into
mainfrom
brunoborges-infer-distribution-from-tool-versions
Jul 8, 2026
Merged

Infer distribution from asdf .tool-versions vendor prefix#1084
brunoborges merged 3 commits into
mainfrom
brunoborges-infer-distribution-from-tool-versions

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

Why

asdf's .tool-versions encodes the JDK vendor as a prefix on the version string (for example java temurin-17.0.3+7 or java corretto-11.0.14.9.1). Until now setup-java discarded that prefix, so users pointing java-version-file at a .tool-versions file still had to pass distribution explicitly. .sdkmanrc already infers the distribution; this brings .tool-versions to parity.

Fixes: #1081

What

  • Reworked the .tool-versions branch of getVersionFromFileContent so the asdf-java vendor prefix is captured in a named distribution group instead of being thrown away. Version parsing is unchanged.
  • Added mapAsdfDistribution() which maps asdf-java vendors to setup-java distributions. Packaging variants such as -jre, -musl, -openj9, -crac, and -javafx collapse onto the base vendor, and the two-segment cases graalvm-community and oracle-graalvm are handled explicitly.
  • Mirrored the existing .sdkmanrc fallback behavior: unknown or unsupported prefixes (for example openjdk, mandrel, trava) emit a warning and fall back to the distribution input. Prefix-less entries like java 17.0.7 keep resolving exactly as before.

No caller changes were needed. setup-java.ts already consumes versionInfo.distribution generically.

Vendor mapping

asdf-java vendor prefix setup-java distribution
temurin, adoptopenjdk temurin
zulu zulu
corretto corretto
liberica liberica
microsoft microsoft
semeru, ibm semeru
dragonwell dragonwell
graalvm, oracle-graalvm graalvm
graalvm-community graalvm-community
oracle oracle
sapmachine sapmachine
kona kona
jetbrains jetbrains

Notes for reviewers

  • adoptopenjdk maps to temurin since AdoptOpenJDK became Eclipse Temurin and setup-java's adopt distribution is deprecated/EOL. This includes the adoptopenjdk-openj9 packaging variants, which collapse onto temurin as well.
  • Existing version-string parsing (including +build metadata retention and the corretto major-only rule) is untouched; only prefix extraction is new.

Testing

  • Added 23 .tool-versions cases in __tests__/util.test.ts covering each supported vendor, prefix-less backward compatibility, and the unknown-prefix warn-and-fall-back path.
  • Full suite passes (878/878); format-check and lint are clean; dist/ regenerated.

asdf-java encodes the JDK vendor as a prefix on the version string in
.tool-versions (e.g. `java temurin-17.0.3+7`). Capture that prefix and
map it to a setup-java distribution, mirroring the existing .sdkmanrc
behavior. Unknown prefixes warn and fall back to the distribution input.

Fixes #1081

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 16:44
@brunoborges brunoborges requested a review from a team as a code owner July 8, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for inferring distribution from asdf-java vendor prefixes in .tool-versions, bringing it in line with the existing .sdkmanrc distribution inference behavior in actions/setup-java.

Changes:

  • Updates .tool-versions parsing to capture an optional vendor prefix into a distribution group and map it to setup-java distributions.
  • Introduces mapAsdfDistribution() to normalize asdf-java vendor identifiers (including multi-segment vendors and packaging variants).
  • Extends documentation and test coverage with supported vendor mappings and example usage.
Show a summary per file
File Description
src/util.ts Captures asdf vendor prefix from .tool-versions, maps it to a setup-java distribution, and threads it through existing version parsing.
__tests__/util.test.ts Adds .tool-versions test cases for supported vendors, prefix-less behavior, and unsupported vendor warnings.
docs/advanced-usage.md Documents .tool-versions vendor-prefix distribution inference and lists supported mappings + example.
dist/setup/index.js Regenerated compiled distribution output reflecting the updated util logic.
dist/cleanup/index.js Regenerated compiled distribution output reflecting the updated util logic.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/5 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread src/util.ts
brunoborges and others added 2 commits July 8, 2026 12:47
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@brunoborges brunoborges merged commit 4db08ef into main Jul 8, 2026
406 checks passed
@brunoborges brunoborges deleted the brunoborges-infer-distribution-from-tool-versions branch July 8, 2026 16:57
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

Successfully merging this pull request may close these issues.

Infer distribution from asdf's .tool-versions file

2 participants