From 8c57fa36276f209f7c545338dc17a4cc89842dec Mon Sep 17 00:00:00 2001 From: Chiranjib Swain Date: Tue, 16 Sep 2025 23:49:02 +0530 Subject: [PATCH 1/2] Clarify JAVA_HOME and PATH setup in README (#841) * Update README to clarify JAVA_HOME and PATH setup * Clarify instructions for setting up multiple JDKs in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ed3c34dc..7addc9a46 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,7 @@ jobs: ### Install multiple JDKs -All versions are added to the PATH. The last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}'. +All configured Java versions are added to the PATH. The last one added to the PATH (i.e., the last JDK set up by this action) will be used as the default and available globally. Other Java versions can be accessed through environment variables such as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}'. To use a specific Java version, set the JAVA_HOME environment variable accordingly and prepend its bin directory to the PATH to ensure it takes priority during execution. ```yaml steps: From ead9eaa3cfe0b0fc2fa749519ae09c3d4f4080b0 Mon Sep 17 00:00:00 2001 From: aparnajyothi-y <147696841+aparnajyothi-y@users.noreply.github.com> Date: Tue, 16 Sep 2025 23:53:22 +0530 Subject: [PATCH 2/2] Update Regex to Support All ASDF Versions for the supported distributions in tool-versions File (#767) * Regex update to fix #719 * Check failures fix * npm run format, npm run format-check & npm run build * Regex update * regex update * fixed check failures * updated regex * regex update for all the versions * regex and docmentation update * Regex update * format and doc update * doc format update * npm audit fix * resolve conflicts * resolve conflicts * resolve conflicts * doc update * Java version upgrade --- dist/cleanup/index.js | 2 +- dist/setup/index.js | 2 +- docs/advanced-usage.md | 4 ++++ package-lock.json | 1 + package.json | 2 +- src/util.ts | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 1822cce21..79ad0b5f4 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 d478f3e8c..c4e8ec9ef 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 226ef1f92..a8a0cc067 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 cf7501446..c99ed7e91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,3 +1,4 @@ + { "name": "setup-java", "version": "5.0.0", diff --git a/package.json b/package.json index 23b833377..21a307695 100644 --- a/package.json +++ b/package.json @@ -60,4 +60,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 af75aaac1..9e5f2f667 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|$)/; }