diff --git a/.github/workflows/e2e-cache-dependency-path.yml b/.github/workflows/e2e-cache-dependency-path.yml index f276ef31..5566165f 100644 --- a/.github/workflows/e2e-cache-dependency-path.yml +++ b/.github/workflows/e2e-cache-dependency-path.yml @@ -30,7 +30,7 @@ jobs: id: setup-java with: distribution: 'adopt' - java-version: '11' + java-version: '17' cache: gradle cache-dependency-path: __tests__/cache/gradle1/*.gradle* - name: Create files to cache diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml index bc685ec0..98184052 100644 --- a/.github/workflows/e2e-cache.yml +++ b/.github/workflows/e2e-cache.yml @@ -30,7 +30,7 @@ jobs: id: setup-java with: distribution: 'adopt' - java-version: '11' + java-version: '17' cache: gradle - name: Create files to cache # Need to avoid using Gradle daemon to stabilize the save process on Windows diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 1822cce2..79ad0b5f 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -94704,7 +94704,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) { const versionFileName = getFileName(versionFile); if (versionFileName == '.tool-versions') { javaVersionRegExp = - /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + /^java\s+(?:\S*-)?(?\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im; } else { javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; diff --git a/dist/setup/index.js b/dist/setup/index.js index d478f3e8..c4e8ec9e 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -132739,7 +132739,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) { const versionFileName = getFileName(versionFile); if (versionFileName == '.tool-versions') { javaVersionRegExp = - /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + /^java\s+(?:\S*-)?(?\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im; } else { javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 4ba80b03..d5e2880e 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -614,5 +614,9 @@ 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***: +For the tool-version file, ensure that you use standard semantic versioning (semver) formats, as non-standard formats (such as jetbrains-21b212.1) may not be parsed correctly. Additionally, for complex version strings containing multiple version-like segments (for example, java semeru-openj9-11.0.15+10_openj9-0.32.0), the extraction logic may incorrectly capture the last segment (0.32.0) instead of the main version (11.0.15+10). \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ef4f83d2..5d59ac3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,3 +1,4 @@ + { "name": "setup-java", "version": "4.0.0", diff --git a/package.json b/package.json index 400a585c..0ccb2d2a 100644 --- a/package.json +++ b/package.json @@ -57,4 +57,4 @@ "url": "https://github.com/actions/setup-java/issues" }, "homepage": "https://github.com/actions/setup-java#readme" -} +} \ No newline at end of file diff --git a/src/util.ts b/src/util.ts index af75aaac..9e5f2f66 100644 --- a/src/util.ts +++ b/src/util.ts @@ -133,7 +133,7 @@ export function getVersionFromFileContent( const versionFileName = getFileName(versionFile); if (versionFileName == '.tool-versions') { javaVersionRegExp = - /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + /^java\s+(?:\S*-)?(?\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im; } else { javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; }