diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 8669d6a..2b8dced 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -344,4 +344,25 @@ describe('installer tests', () => { expect(thrown).toBe(true); return; }); + + it('GitHub issue #9: Allow openjdk[0-9]+ as Java release version', async () => { + await installer.getAdoptOpenJDK( + 'ga', + 'openjdk14', + 'jdk', + 'hotspot', + 'x64', + 'normal', + 'latest', + '' + ); + const JavaDir = path.join( + toolDir, + toolName, + `1.0.0-ga-14-jdk-hotspot-${os}-x64-normal-latest`, + 'x64' + ); + + expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true); + }, 100000); }); diff --git a/dist/index.js b/dist/index.js index 2bed2a6..a5042e5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4687,13 +4687,13 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); let tempDirectory = process.env['RUNNER_TEMP'] || ''; const core = __importStar(__webpack_require__(470)); -const io = __importStar(__webpack_require__(1)); const exec = __importStar(__webpack_require__(986)); -const httpm = __importStar(__webpack_require__(539)); -const tc = __importStar(__webpack_require__(533)); const fs = __importStar(__webpack_require__(747)); +const httpm = __importStar(__webpack_require__(539)); +const io = __importStar(__webpack_require__(1)); const path = __importStar(__webpack_require__(622)); const semver = __importStar(__webpack_require__(280)); +const tc = __importStar(__webpack_require__(533)); const IS_WINDOWS = process.platform === 'win32'; const IS_MACOS = process.platform === 'darwin'; const toolName = 'AdoptOpenJDK'; @@ -5008,7 +5008,8 @@ function getJdkDirectory(destinationFolder) { function downloadJavaBinary(release_type, version, image_type, jvm_impl, os, arch, heap_size, release, jdkFile) { return __awaiter(this, void 0, void 0, function* () { const normalizedArchitecture = architectureAliases.get(arch) || arch; - const versionSpec = getCacheVersionSpec(release_type, version, image_type, jvm_impl, os, normalizedArchitecture, heap_size, release); + const normalizedVersion = version.replace('openjdk', ''); + const versionSpec = getCacheVersionSpec(release_type, normalizedVersion, image_type, jvm_impl, os, normalizedArchitecture, heap_size, release); let toolPath = tc.find(toolName, versionSpec, normalizedArchitecture); if (toolPath) { core.debug(`Tool found in cache ${toolPath}`); @@ -5017,7 +5018,8 @@ function downloadJavaBinary(release_type, version, image_type, jvm_impl, os, arc let compressedFileExtension = ''; if (!jdkFile) { core.debug('Downloading JDK from AdoptOpenJDK'); - const url = getAdoptOpenJdkUrl(release_type, version, image_type, jvm_impl, os, normalizedArchitecture, heap_size, release); + const url = getAdoptOpenJdkUrl(release_type, normalizedVersion, image_type, jvm_impl, os, normalizedArchitecture, heap_size, release); + core.debug(`AdoptOpenJDK URL: ${url}`); jdkFile = yield tc.downloadTool(url); compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz'; } @@ -5027,7 +5029,7 @@ function downloadJavaBinary(release_type, version, image_type, jvm_impl, os, arc core.debug(`JDK extracted to ${jdkDir}`); toolPath = yield tc.cacheDir(jdkDir, toolName, versionSpec, normalizedArchitecture); } - let extendedJavaHome = `JAVA_HOME_${version}_${normalizedArchitecture}`; + let extendedJavaHome = `JAVA_HOME_${normalizedVersion}_${normalizedArchitecture}`; core.exportVariable(extendedJavaHome, toolPath); //TODO: remove for v2 // For portability reasons environment variables should only consist of // uppercase letters, digits, and the underscore. Therefore we convert @@ -5038,7 +5040,7 @@ function downloadJavaBinary(release_type, version, image_type, jvm_impl, os, arc core.exportVariable(extendedJavaHome, toolPath); core.addPath(path.join(toolPath, 'bin')); core.setOutput('path', toolPath); - core.setOutput('version', version); + core.setOutput('version', normalizedVersion); }); } diff --git a/src/installer.ts b/src/installer.ts index d71d300..37b40e8 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -1,13 +1,13 @@ let tempDirectory = process.env['RUNNER_TEMP'] || ''; import * as core from '@actions/core'; -import * as io from '@actions/io'; import * as exec from '@actions/exec'; -import * as httpm from '@actions/http-client'; -import * as tc from '@actions/tool-cache'; import * as fs from 'fs'; +import * as httpm from '@actions/http-client'; +import * as io from '@actions/io'; import * as path from 'path'; import * as semver from 'semver'; +import * as tc from '@actions/tool-cache'; const IS_WINDOWS = process.platform === 'win32'; const IS_MACOS = process.platform === 'darwin'; @@ -408,9 +408,10 @@ async function downloadJavaBinary( jdkFile: string ): Promise { const normalizedArchitecture = architectureAliases.get(arch) || arch; + const normalizedVersion = version.replace('openjdk', ''); const versionSpec = getCacheVersionSpec( release_type, - version, + normalizedVersion, image_type, jvm_impl, os, @@ -428,7 +429,7 @@ async function downloadJavaBinary( core.debug('Downloading JDK from AdoptOpenJDK'); const url: string = getAdoptOpenJdkUrl( release_type, - version, + normalizedVersion, image_type, jvm_impl, os, @@ -436,6 +437,7 @@ async function downloadJavaBinary( heap_size, release ); + core.debug(`AdoptOpenJDK URL: ${url}`); jdkFile = await tc.downloadTool(url); compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz'; } @@ -459,7 +461,7 @@ async function downloadJavaBinary( ); } - let extendedJavaHome = `JAVA_HOME_${version}_${normalizedArchitecture}`; + let extendedJavaHome = `JAVA_HOME_${normalizedVersion}_${normalizedArchitecture}`; core.exportVariable(extendedJavaHome, toolPath); //TODO: remove for v2 // For portability reasons environment variables should only consist of // uppercase letters, digits, and the underscore. Therefore we convert @@ -470,5 +472,5 @@ async function downloadJavaBinary( core.exportVariable(extendedJavaHome, toolPath); core.addPath(path.join(toolPath, 'bin')); core.setOutput('path', toolPath); - core.setOutput('version', version); + core.setOutput('version', normalizedVersion); }