mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 18:06:45 +00:00
Add support for JDKs with JavaFX
Also changes the toolcache to 'fx-jdk' for JDKs with JavaFX and 'jdk' for JDKs without JavaFX
This commit is contained in:
parent
91b87ac691
commit
654e4df6f4
6 changed files with 46 additions and 25 deletions
|
@ -1,9 +1,10 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
|
@ -41,9 +42,9 @@ if (!tempDirectory) {
|
|||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
function getJava(version, arch, jdkFile) {
|
||||
function getJava(version, arch, jdkFile, javafx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let toolPath = tc.find('Java', version);
|
||||
let toolPath = tc.find(javafx ? 'fx-jdk' : 'jdk', version);
|
||||
if (toolPath) {
|
||||
core.debug(`Tool found in cache ${toolPath}`);
|
||||
}
|
||||
|
@ -54,7 +55,7 @@ function getJava(version, arch, jdkFile) {
|
|||
let http = new httpm.HttpClient('setup-java');
|
||||
let contents = yield (yield http.get('https://static.azul.com/zulu/bin/')).readBody();
|
||||
let refs = contents.match(/<a href.*\">/gi) || [];
|
||||
const downloadInfo = getDownloadInfo(refs, version);
|
||||
const downloadInfo = getDownloadInfo(refs, version, javafx);
|
||||
jdkFile = yield tc.downloadTool(downloadInfo.url);
|
||||
version = downloadInfo.version;
|
||||
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
|
||||
|
@ -66,7 +67,7 @@ function getJava(version, arch, jdkFile) {
|
|||
let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000));
|
||||
const jdkDir = yield unzipJavaDownload(jdkFile, compressedFileExtension, tempDir);
|
||||
core.debug(`jdk extracted to ${jdkDir}`);
|
||||
toolPath = yield tc.cacheDir(jdkDir, 'Java', getCacheVersionString(version), arch);
|
||||
toolPath = yield tc.cacheDir(jdkDir, javafx ? 'fx-jdk' : 'jdk', getCacheVersionString(version), arch);
|
||||
}
|
||||
let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch;
|
||||
core.exportVariable('JAVA_HOME', toolPath);
|
||||
|
@ -162,7 +163,7 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) {
|
|||
}
|
||||
});
|
||||
}
|
||||
function getDownloadInfo(refs, version) {
|
||||
function getDownloadInfo(refs, version, javafx) {
|
||||
version = normalizeVersion(version);
|
||||
let extension = '';
|
||||
if (IS_WINDOWS) {
|
||||
|
@ -185,13 +186,18 @@ function getDownloadInfo(refs, version) {
|
|||
}
|
||||
// If we haven't returned, means we're looking at the correct platform
|
||||
let versions = ref.match(/jdk.*-/gi) || [];
|
||||
if (javafx) { // If getting a JDK with JavaFX, the version prefix is different
|
||||
versions = ref.match(/ca-fx-jdk.*-/gi) || [];
|
||||
}
|
||||
if (versions.length > 1) {
|
||||
throw new Error(`Invalid ref received from https://static.azul.com/zulu/bin/: ${ref}`);
|
||||
}
|
||||
if (versions.length == 0) {
|
||||
return;
|
||||
}
|
||||
const refVersion = versions[0].slice('jdk'.length, versions[0].length - 1);
|
||||
// If getting a JDK with JavaFX, the version prefix is different
|
||||
let jdkVersionPrefix = javafx ? 'ca-fx-jdk' : 'jdk';
|
||||
const refVersion = versions[0].slice(jdkVersionPrefix.length, versions[0].length - 1);
|
||||
if (semver.satisfies(refVersion, version)) {
|
||||
versionMap.set(refVersion, 'https://static.azul.com/zulu/bin/' +
|
||||
ref.slice('<a href="'.length, ref.length - '">'.length));
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
|
@ -27,7 +28,8 @@ function run() {
|
|||
}
|
||||
const arch = core.getInput('architecture', { required: true });
|
||||
const jdkFile = core.getInput('jdkFile', { required: false }) || '';
|
||||
yield installer.getJava(version, arch, jdkFile);
|
||||
const javafx = core.getInput('javafx', { required: false }) == 'true';
|
||||
yield installer.getJava(version, arch, jdkFile, javafx);
|
||||
const matchersPath = path.join(__dirname, '..', '.github');
|
||||
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue