mirror of
https://github.com/actions/setup-java.git
synced 2025-04-08 14:00:14 +08:00
Allow java to be found in cache
This commit is contained in:
parent
84817402a9
commit
8a70afdf57
@ -39,9 +39,9 @@ if (!tempDirectory) {
|
|||||||
}
|
}
|
||||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||||
}
|
}
|
||||||
function getJava(versionSpec, arch, jdkFile) {
|
function getJava(version, arch, jdkFile) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let toolPath = tc.find('Java', versionSpec);
|
let toolPath = tc.find('Java', version);
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.debug(`Tool found in cache ${toolPath}`);
|
core.debug(`Tool found in cache ${toolPath}`);
|
||||||
}
|
}
|
||||||
@ -51,9 +51,9 @@ function getJava(versionSpec, arch, jdkFile) {
|
|||||||
let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000));
|
let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000));
|
||||||
const jdkDir = yield unzipJavaDownload(jdkFile, compressedFileExtension, tempDir);
|
const jdkDir = yield unzipJavaDownload(jdkFile, compressedFileExtension, tempDir);
|
||||||
core.debug(`jdk extracted to ${jdkDir}`);
|
core.debug(`jdk extracted to ${jdkDir}`);
|
||||||
toolPath = yield tc.cacheDir(jdkDir, 'Java', versionSpec, arch);
|
toolPath = yield tc.cacheDir(jdkDir, 'Java', `${version}.0.0`, arch);
|
||||||
}
|
}
|
||||||
let extendedJavaHome = 'JAVA_HOME_' + versionSpec + '_' + arch;
|
let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch;
|
||||||
core.exportVariable('JAVA_HOME', toolPath);
|
core.exportVariable('JAVA_HOME', toolPath);
|
||||||
core.exportVariable(extendedJavaHome, toolPath);
|
core.exportVariable(extendedJavaHome, toolPath);
|
||||||
core.addPath(path.join(toolPath, 'bin'));
|
core.addPath(path.join(toolPath, 'bin'));
|
||||||
|
@ -25,11 +25,11 @@ if (!tempDirectory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getJava(
|
export async function getJava(
|
||||||
versionSpec: string,
|
version: string,
|
||||||
arch: string,
|
arch: string,
|
||||||
jdkFile: string
|
jdkFile: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
let toolPath = tc.find('Java', versionSpec);
|
let toolPath = tc.find('Java', version);
|
||||||
|
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.debug(`Tool found in cache ${toolPath}`);
|
core.debug(`Tool found in cache ${toolPath}`);
|
||||||
@ -46,10 +46,10 @@ export async function getJava(
|
|||||||
tempDir
|
tempDir
|
||||||
);
|
);
|
||||||
core.debug(`jdk extracted to ${jdkDir}`);
|
core.debug(`jdk extracted to ${jdkDir}`);
|
||||||
toolPath = await tc.cacheDir(jdkDir, 'Java', versionSpec, arch);
|
toolPath = await tc.cacheDir(jdkDir, 'Java', `${version}.0.0`, arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
let extendedJavaHome = 'JAVA_HOME_' + versionSpec + '_' + arch;
|
let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch;
|
||||||
core.exportVariable('JAVA_HOME', toolPath);
|
core.exportVariable('JAVA_HOME', toolPath);
|
||||||
core.exportVariable(extendedJavaHome, toolPath);
|
core.exportVariable(extendedJavaHome, toolPath);
|
||||||
core.addPath(path.join(toolPath, 'bin'));
|
core.addPath(path.join(toolPath, 'bin'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user