Support multi-field Java versions like 18.0.1.1#1092
Merged
Conversation
Java's version scheme (JEP 322) can contain more than the three numeric fields SemVer allows, e.g. 18.0.1.1 or 11.0.9.1. normalizeVersion() rejected these inputs. Convert exact multi-field versions to SemVer build notation (18.0.1.1 -> 18.0.1+1) before validation, reusing the existing convertVersionToSemver() helper. Ranges, EA tags, and inputs that already carry build metadata are left untouched. Fixes: #326 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates actions/setup-java to accept exact Java versions that use JEP 322’s multi-field numeric format (e.g. 18.0.1.1) by normalizing them into SemVer build-metadata form (e.g. 18.0.1+1) before SemVer validation. This aligns actual behavior with the README’s “exact/specific version” examples and fixes the reported input-validation failure.
Changes:
- Normalize 4+ numeric-field exact version inputs in
JavaBase.normalizeVersion()via existingconvertVersionToSemver()prior tosemver.validRange()validation. - Document multi-field Java version inputs in the README “Supported version syntax”.
- Add test coverage for multi-field exact versions (and an EA variant) in
normalizeVersion.
Show a summary per file
| File | Description |
|---|---|
| src/distributions/base-installer.ts | Normalizes multi-field numeric Java versions into SemVer build metadata prior to validation. |
| README.md | Documents that multi-field JEP 322 versions like 11.0.9.1 / 18.0.1.1 are supported inputs. |
| dist/setup/index.js | Updates the compiled distribution output to include the new normalization logic. |
| tests/distributors/base-installer.test.ts | Adds normalizeVersion test cases covering multi-field versions and an EA variant. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/4 changed files
- Comments generated: 0
- Review effort level: Low
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Java's version scheme (JEP 322) can contain more than the three numeric fields that SemVer allows, for example
18.0.1.1or11.0.9.1(the re-released11.0.9urgent fix). Passing such a value tojava-versionfailed withThe string '18.0.1.1' is not valid SemVer notation for a Java version, even though the README examples imply these exact/specific versions are supported.This change normalizes exact multi-field versions into SemVer build notation before validation, reusing the existing
convertVersionToSemver()helper (already used when parsing remote version lists):18.0.1.1becomes18.0.1+1. The conversion is guarded by a strict regex (/^\d+(\.\d+){3,}$/) so version ranges, EA tags, and inputs that already carry+buildmetadata are left untouched. No downstream changes were needed:isVersionSatisfies()already compares build-metadata versions viasemver.compareBuild, and the tool-cache path naming already maps+to-.Related issue:
Fixes: #326
Check list:
npm run checklocally (format, lint, build, test) and all checks pass.normalizeVersioncases for18.0.1.1,11.0.9.1,12.0.2.1.0, and an EA variant.)