Skip to content

Update Regex to Support All ASDF Versions for the supported distributions in tool-versions File #767

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-immutable-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
release:
types: [released]
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -18,4 +17,5 @@ jobs:
uses: actions/checkout@v4
- name: Publish
id: publish

uses: actions/[email protected]
2 changes: 1 addition & 1 deletion dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93634,7 +93634,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
const versionFileName = getFileName(versionFile);
if (versionFileName == '.tool-versions') {
javaVersionRegExp =
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+){0,2}(?:[+_]\d+)?)(?=(?:[-_](?!\d))|$)(?:[-_.](?:ea|LTS|beta|snapshot|internal|b\d+|\d+[a-z]*))*$/im;
}
else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
Expand Down
2 changes: 1 addition & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131639,7 +131639,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
const versionFileName = getFileName(versionFile);
if (versionFileName == '.tool-versions') {
javaVersionRegExp =
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+){0,2}(?:[+_]\d+)?)(?=(?:[-_](?!\d))|$)(?:[-_.](?:ea|LTS|beta|snapshot|internal|b\d+|\d+[a-z]*))*$/im;
}
else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
Expand Down
9 changes: 9 additions & 0 deletions docs/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,5 +614,14 @@ major versions: 8, 11, 16, 17, 21
more specific versions: 8.0.282+8, 8.0.232, 11.0, 11.0.4, 17.0
early access (EA) versions: 15-ea, 15.0.0-ea
versions with specified distribution: openjdk64-11.0.2
LTS versions : temurin-21.0.5+11.0.LTS
```
If the file contains multiple versions, only the first one will be recognized.
```
Note:
In some complex version strings containing multiple version-like segments (e.g., java semeru-openj9-11.0.15+10_openj9-0.32.0),
the regular expression may extract the last version segment (0.32.0) instead of the intended main version (11.0.15+10).
Additionally, the regex is designed to support standard semantic versioning (semver) formats
and may not correctly parse non-standard formats such as jetbrains-21b212.1.
Users are encouraged to provide clear, semver-compliant version specifications to ensure accurate extraction.
```
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function getVersionFromFileContent(
const versionFileName = getFileName(versionFile);
if (versionFileName == '.tool-versions') {
javaVersionRegExp =
/^(java\s+)(?:\S*-)?v?(?<version>(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m;
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+){0,2}(?:[+_]\d+)?)(?=(?:[-_](?!\d))|$)(?:[-_.](?:ea|LTS|beta|snapshot|internal|b\d+|\d+[a-z]*))*$/im;
} else {
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
}
Expand Down
Loading