Skip to content

Support inferring distribution from .java-version and .tool-versions files#1076

Closed
brunoborges with Copilot wants to merge 3 commits into
mainfrom
copilot/check-distribution-java-version
Closed

Support inferring distribution from .java-version and .tool-versions files#1076
brunoborges with Copilot wants to merge 3 commits into
mainfrom
copilot/check-distribution-java-version

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description:

Makes the distribution input optional when a version file already names a distribution. Previously only .sdkmanrc (suffix, e.g. java=21.0.5-tem) could infer the distribution; this extends inference to jenv-style .java-version and asdf-style .tool-versions files using a distribution prefix.

# .java-version
temurin-21.0.5

# .tool-versions
java temurin-21.0.5
  • Parsing (src/util.ts)getVersionFromFileContent now captures an optional distribution identifier from .java-version and .tool-versions, in addition to the existing .sdkmanrc suffix handling. Version extraction is unchanged.
  • Mapping — New mapJavaVersionFileDistribution validates the identifier against SUPPORTED_DISTRIBUTIONS (src/constants.ts), stripping arch suffixes (temurin64temurin). Unsupported/generic prefixes (e.g. openjdk64) are ignored, falling back to the distribution input so existing behavior is preserved.
  • Docs — Updated README.md, action.yml, and docs/advanced-usage.md to describe prefix-based inference.
  • Tests — Added .java-version/.tool-versions unit cases in __tests__/util.test.ts (including the hyphen-separator edge case) and an e2e job in e2e-versions.yml that installs with the distribution inferred and no distribution input.

Note: when a file specifies a supported distribution, it takes precedence over the distribution input.

Check list:

  • Ran npm run check locally (format, lint, build, test) and all checks pass.
  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Copilot AI linked an issue Jul 7, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Make distribution field optional in setup-java Support inferring distribution from .java-version and .tool-versions files Jul 7, 2026
Copilot AI requested a review from brunoborges July 7, 2026 19:23
@brunoborges

Copy link
Copy Markdown
Contributor

@copilot .java-version file format does not accept distribution

@brunoborges brunoborges closed this Jul 7, 2026
@brunoborges brunoborges deleted the copilot/check-distribution-java-version branch July 8, 2026 15:23
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.

Specify distribution via java-version-file

2 participants