diff --git a/README.md b/README.md index 614bb20e..0edc4178 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,13 @@ The `setup-java` action provides the following functionality for GitHub Actions This action allows you to work with Java and Scala projects. +## Breaking changes in V5 + +- Upgraded action from node20 to node24 + > Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release [Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1) + +For more details, see the full release notes on the [releases page](https://github.com/actions/setup-java/releases/tag/v5.0.0) + ## V2 vs V1 - V2 supports custom distributions and provides support for Azul Zulu OpenJDK, Eclipse Temurin and AdoptOpenJDK out of the box. V1 supports only Azul Zulu OpenJDK. @@ -239,7 +246,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: diff --git a/__tests__/distributors/corretto-installer.test.ts b/__tests__/distributors/corretto-installer.test.ts index 0604603f..1da5e393 100644 --- a/__tests__/distributors/corretto-installer.test.ts +++ b/__tests__/distributors/corretto-installer.test.ts @@ -150,9 +150,8 @@ describe('getAvailableVersions', () => { }); mockPlatform(distribution, platform); - const availableVersion = await distribution['findPackageForDownload']( - version - ); + const availableVersion = + await distribution['findPackageForDownload'](version); expect(availableVersion).not.toBeNull(); expect(availableVersion.url).toBe(expectedLink); }); @@ -222,9 +221,8 @@ describe('getAvailableVersions', () => { const expectedLink = `https://corretto.aws/downloads/resources/17.0.2.8.1/amazon-corretto-17.0.2.8.1-macosx-${distroArch}.tar.gz`; - const availableVersion = await distribution['findPackageForDownload']( - '17' - ); + const availableVersion = + await distribution['findPackageForDownload']('17'); expect(availableVersion).not.toBeNull(); expect(availableVersion.url).toBe(expectedLink); } diff --git a/__tests__/distributors/dragonwell-installer.test.ts b/__tests__/distributors/dragonwell-installer.test.ts index 4a680d8f..627a96ab 100644 --- a/__tests__/distributors/dragonwell-installer.test.ts +++ b/__tests__/distributors/dragonwell-installer.test.ts @@ -206,9 +206,8 @@ describe('getAvailableVersions', () => { }); mockPlatform(distribution, platform); - const availableVersion = await distribution['findPackageForDownload']( - jdkVersion - ); + const availableVersion = + await distribution['findPackageForDownload'](jdkVersion); expect(availableVersion).not.toBeNull(); expect(availableVersion.url).toBe(expectedLink); } diff --git a/__tests__/distributors/jetbrains-installer.test.ts b/__tests__/distributors/jetbrains-installer.test.ts index 241843cc..44d8ef89 100644 --- a/__tests__/distributors/jetbrains-installer.test.ts +++ b/__tests__/distributors/jetbrains-installer.test.ts @@ -76,9 +76,8 @@ describe('findPackageForDownload', () => { checkLatest: false }); distribution['getAvailableVersions'] = async () => manifestData as any; - const resolvedVersion = await distribution['findPackageForDownload']( - input - ); + const resolvedVersion = + await distribution['findPackageForDownload'](input); const url = resolvedVersion.url; const options = {method: 'HEAD'}; diff --git a/__tests__/distributors/sapmachine-installer.test.ts b/__tests__/distributors/sapmachine-installer.test.ts index 4eec570a..5073cd9f 100644 --- a/__tests__/distributors/sapmachine-installer.test.ts +++ b/__tests__/distributors/sapmachine-installer.test.ts @@ -61,9 +61,8 @@ describe('getAvailableVersions', () => { mockPlatform(distribution, 'linux'); - const availableVersion = await distribution['findPackageForDownload']( - version - ); + const availableVersion = + await distribution['findPackageForDownload'](version); expect(availableVersion).not.toBeNull(); expect(availableVersion.url).toBe( 'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-x64_bin.tar.gz' @@ -230,9 +229,8 @@ describe('getAvailableVersions', () => { }); mockPlatform(distribution, platform); - const availableVersion = await distribution['findPackageForDownload']( - normalizedVersion - ); + const availableVersion = + await distribution['findPackageForDownload'](normalizedVersion); expect(availableVersion).not.toBeNull(); expect(availableVersion.url).toBe(expectedLink); } 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 226ef1f9..a8a0cc06 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 336c19e7..c99ed7e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,3 +1,4 @@ + { "name": "setup-java", "version": "5.0.0", @@ -32,7 +33,7 @@ "eslint-plugin-node": "^11.1.0", "jest": "^29.7.0", "jest-circus": "^29.7.0", - "prettier": "^2.8.4", + "prettier": "^3.6.2", "ts-jest": "^29.3.0", "typescript": "^5.3.3" }, @@ -4876,15 +4877,16 @@ } }, "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, + "license": "MIT", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" diff --git a/package.json b/package.json index bccf0321..21a30769 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "description": "setup java action", "main": "dist/setup/index.js", - "engines": { + "engines": { "node": ">=24.0.0" }, "scripts": { @@ -52,7 +52,7 @@ "eslint-plugin-node": "^11.1.0", "jest": "^29.7.0", "jest-circus": "^29.7.0", - "prettier": "^2.8.4", + "prettier": "^3.6.2", "ts-jest": "^29.3.0", "typescript": "^5.3.3" }, @@ -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/toolchains.ts b/src/toolchains.ts index cbb667eb..77cae83f 100644 --- a/src/toolchains.ts +++ b/src/toolchains.ts @@ -59,9 +59,8 @@ export async function createToolchainsSettings({ // when an alternate m2 location is specified use only that location (no .m2 directory) // otherwise use the home/.m2/ path await io.mkdirP(settingsDirectory); - const originalToolchains = await readExistingToolchainsFile( - settingsDirectory - ); + const originalToolchains = + await readExistingToolchainsFile(settingsDirectory); const updatedToolchains = generateToolchainDefinition( originalToolchains, jdkInfo.version, 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|$)/; }