Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Restore compatibility with joschi/setup-jdk@v1 for java-version
Browse files Browse the repository at this point in the history
The normalization of the `java-version` setting to treat "openjdk14" as
a valid Java release version was accidentally dropped while moving to
joschi/setup-jdk 2.x.

Closes #9
  • Loading branch information
joschi committed Jul 20, 2020
1 parent 5f767b2 commit eea40c6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
21 changes: 21 additions & 0 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,25 @@ describe('installer tests', () => {
expect(thrown).toBe(true);
return;
});

it('GitHub issue #9: Allow openjdk\d+ 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);
});
16 changes: 9 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions src/installer.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -408,9 +408,10 @@ async function downloadJavaBinary(
jdkFile: string
): Promise<void> {
const normalizedArchitecture = architectureAliases.get(arch) || arch;
const normalizedVersion = version.replace('openjdk', '');
const versionSpec = getCacheVersionSpec(
release_type,
version,
normalizedVersion,
image_type,
jvm_impl,
os,
Expand All @@ -428,14 +429,15 @@ async function downloadJavaBinary(
core.debug('Downloading JDK from AdoptOpenJDK');
const url: string = getAdoptOpenJdkUrl(
release_type,
version,
normalizedVersion,
image_type,
jvm_impl,
os,
normalizedArchitecture,
heap_size,
release
);
core.debug(`AdoptOpenJDK URL: ${url}`);
jdkFile = await tc.downloadTool(url);
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
}
Expand All @@ -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
Expand All @@ -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);
}

0 comments on commit eea40c6

Please sign in to comment.