mirror of
https://github.com/actions/setup-java.git
synced 2025-04-19 17:36:45 +00:00
Fix
This commit is contained in:
parent
c38b0fe09c
commit
55f787ebb1
2 changed files with 11 additions and 16 deletions
|
@ -47,11 +47,13 @@ function getJava(version, arch, jdkFile) {
|
||||||
core.debug(`Tool found in cache ${toolPath}`);
|
core.debug(`Tool found in cache ${toolPath}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
let compressedFileExtension = '';
|
||||||
if (!jdkFile) {
|
if (!jdkFile) {
|
||||||
jdkFile = yield downloadJava(version);
|
jdkFile = yield downloadJava(version);
|
||||||
|
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
|
||||||
}
|
}
|
||||||
core.debug('Retrieving Jdk from local path');
|
core.debug('Retrieving Jdk from local path');
|
||||||
const compressedFileExtension = getFileEnding(jdkFile);
|
compressedFileExtension = compressedFileExtension || getFileEnding(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}`);
|
||||||
|
@ -127,7 +129,7 @@ function unpackJars(fsPath, javaBinPath) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function unzipJavaDownload(repoRoot, fileEnding, destinationFolder) {
|
function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Create the destination folder if it doesn't exist
|
// Create the destination folder if it doesn't exist
|
||||||
yield io.mkdirP(destinationFolder);
|
yield io.mkdirP(destinationFolder);
|
||||||
|
@ -170,10 +172,6 @@ function downloadJava(version) {
|
||||||
throw new Error(`No valid download found for version ${version}. Check https://static.azul.com/zulu/bin/ for a list of valid versions or download your own jdk file and add the jdkFile argument`);
|
throw new Error(`No valid download found for version ${version}. Check https://static.azul.com/zulu/bin/ for a list of valid versions or download your own jdk file and add the jdkFile argument`);
|
||||||
}
|
}
|
||||||
const fileName = refs[0].slice('<a href="'.length, refs[0].length - '">'.length);
|
const fileName = refs[0].slice('<a href="'.length, refs[0].length - '">'.length);
|
||||||
const dest = yield tc.downloadTool(`https://static.azul.com/zulu/bin/${fileName}`);
|
return yield tc.downloadTool(`https://static.azul.com/zulu/bin/${fileName}`);
|
||||||
if (dest) {
|
|
||||||
throw new Error(fs.readdirSync(dest).toString());
|
|
||||||
}
|
|
||||||
return path.join(dest, fileName);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,13 @@ export async function getJava(
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.debug(`Tool found in cache ${toolPath}`);
|
core.debug(`Tool found in cache ${toolPath}`);
|
||||||
} else {
|
} else {
|
||||||
|
let compressedFileExtension = '';
|
||||||
if (!jdkFile) {
|
if (!jdkFile) {
|
||||||
jdkFile = await downloadJava(version);
|
jdkFile = await downloadJava(version);
|
||||||
|
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
|
||||||
}
|
}
|
||||||
core.debug('Retrieving Jdk from local path');
|
core.debug('Retrieving Jdk from local path');
|
||||||
const compressedFileExtension = getFileEnding(jdkFile);
|
compressedFileExtension = compressedFileExtension || getFileEnding(jdkFile);
|
||||||
let tempDir: string = path.join(
|
let tempDir: string = path.join(
|
||||||
tempDirectory,
|
tempDirectory,
|
||||||
'temp_' + Math.floor(Math.random() * 2000000000)
|
'temp_' + Math.floor(Math.random() * 2000000000)
|
||||||
|
@ -123,7 +125,8 @@ async function unpackJars(fsPath: string, javaBinPath: string) {
|
||||||
async function unzipJavaDownload(
|
async function unzipJavaDownload(
|
||||||
repoRoot: string,
|
repoRoot: string,
|
||||||
fileEnding: string,
|
fileEnding: string,
|
||||||
destinationFolder: string
|
destinationFolder: string,
|
||||||
|
extension?: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// Create the destination folder if it doesn't exist
|
// Create the destination folder if it doesn't exist
|
||||||
await io.mkdirP(destinationFolder);
|
await io.mkdirP(destinationFolder);
|
||||||
|
@ -175,11 +178,5 @@ async function downloadJava(version: string): Promise<string> {
|
||||||
'<a href="'.length,
|
'<a href="'.length,
|
||||||
refs[0].length - '">'.length
|
refs[0].length - '">'.length
|
||||||
);
|
);
|
||||||
const dest = await tc.downloadTool(
|
return await tc.downloadTool(`https://static.azul.com/zulu/bin/${fileName}`);
|
||||||
`https://static.azul.com/zulu/bin/${fileName}`
|
|
||||||
);
|
|
||||||
if (dest) {
|
|
||||||
throw new Error(fs.readdirSync(dest).toString());
|
|
||||||
}
|
|
||||||
return path.join(dest, fileName);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue