mirror of
https://github.com/actions/setup-java.git
synced 2026-07-08 17:46:21 +00:00
dist: Support Tencent Kona JDK (#672)
* Support Tencent Kona JDK (#672) Signed-off-by: John Jiang <johnsjiang@tencent.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Address Copilot review feedback for Kona distribution - Sort matching releases by semver descending so range versions (e.g. >=17) resolve to the newest matching Kona JDK instead of the lowest - Rename downloaded archive on Windows before extraction (renameWinArchive) to avoid extraction failures - Import semver for version sorting Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: John Jiang <johnsjiang@tencent.com> Co-authored-by: Bruno Borges <brborges@microsoft.com> Co-authored-by: Bruno Borges <bruno.borges@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Vendored
+184
@@ -78771,6 +78771,7 @@ const installer_10 = __nccwpck_require__(37675);
|
||||
const installer_11 = __nccwpck_require__(17557);
|
||||
const installer_12 = __nccwpck_require__(26968);
|
||||
const installer_13 = __nccwpck_require__(62282);
|
||||
const installer_14 = __nccwpck_require__(48151);
|
||||
var JavaDistribution;
|
||||
(function (JavaDistribution) {
|
||||
JavaDistribution["Adopt"] = "adopt";
|
||||
@@ -78789,6 +78790,7 @@ var JavaDistribution;
|
||||
JavaDistribution["GraalVM"] = "graalvm";
|
||||
JavaDistribution["GraalVMCommunity"] = "graalvm-community";
|
||||
JavaDistribution["JetBrains"] = "jetbrains";
|
||||
JavaDistribution["Kona"] = "kona";
|
||||
})(JavaDistribution || (JavaDistribution = {}));
|
||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
switch (distributionName) {
|
||||
@@ -78823,6 +78825,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
return new installer_12.GraalVMCommunityDistribution(installerOptions);
|
||||
case JavaDistribution.JetBrains:
|
||||
return new installer_13.JetBrainsDistribution(installerOptions);
|
||||
case JavaDistribution.Kona:
|
||||
return new installer_14.KonaDistribution(installerOptions);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -79602,6 +79606,186 @@ class JetBrainsDistribution extends base_installer_1.JavaBase {
|
||||
exports.JetBrainsDistribution = JetBrainsDistribution;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 48151:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
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) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.KonaDistribution = void 0;
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const tc = __importStar(__nccwpck_require__(33472));
|
||||
const semver_1 = __importDefault(__nccwpck_require__(62088));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(79896));
|
||||
const path_1 = __importDefault(__nccwpck_require__(16928));
|
||||
const base_installer_1 = __nccwpck_require__(79935);
|
||||
const util_1 = __nccwpck_require__(54527);
|
||||
class KonaDistribution extends base_installer_1.JavaBase {
|
||||
constructor(installerOptions) {
|
||||
super('Kona', installerOptions);
|
||||
}
|
||||
downloadTool(javaRelease) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info(`Downloading Kona JDK ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||
core.info(`Extracting Java archive...`);
|
||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||
const archivePath = process.platform === 'win32'
|
||||
? (0, util_1.renameWinArchive)(javaArchivePath)
|
||||
: javaArchivePath;
|
||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(archivePath, extension);
|
||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||
const jdkDirectory = path_1.default.join(extractedJavaPath, archiveName);
|
||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||
const javaPath = yield tc.cacheDir(jdkDirectory, this.toolcacheFolderName, version, this.architecture);
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
});
|
||||
}
|
||||
findPackageForDownload(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!this.stable) {
|
||||
throw new Error('Kona provides stable releases only');
|
||||
}
|
||||
if (this.packageType !== 'jdk') {
|
||||
throw new Error('Kona provides jdk only');
|
||||
}
|
||||
const availableReleases = yield this.getAvailableReleases();
|
||||
const releases = availableReleases
|
||||
.filter(item => {
|
||||
return (0, util_1.isVersionSatisfies)(version, item.version);
|
||||
})
|
||||
.map(item => {
|
||||
return {
|
||||
version: item.version,
|
||||
url: item.downloadUrl
|
||||
};
|
||||
})
|
||||
.sort((a, b) => -semver_1.default.compareBuild(a.version, b.version));
|
||||
if (!releases.length) {
|
||||
throw new Error(`No Kona release for the specified version "${version}" on OS "${this.getOs()}" and arch "${this.getArch()}".`);
|
||||
}
|
||||
return releases[0];
|
||||
});
|
||||
}
|
||||
getAvailableReleases() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (core.isDebug()) {
|
||||
console.time('Retrieving available releases for Kona took'); // eslint-disable-line no-console
|
||||
}
|
||||
const releaseInfo = yield this.fetchReleaseInfo();
|
||||
if (!releaseInfo) {
|
||||
throw new Error(`Couldn't fetch Kona release information`);
|
||||
}
|
||||
const availableReleases = this.chooseReleases(this.getOs(), this.getArch(), releaseInfo);
|
||||
if (core.isDebug()) {
|
||||
core.startGroup('Print information about available releases');
|
||||
console.timeEnd('Retrieving available releases for Kona took'); // eslint-disable-line no-console
|
||||
core.debug(availableReleases.map(item => item.version).join(', '));
|
||||
core.endGroup();
|
||||
}
|
||||
return availableReleases;
|
||||
});
|
||||
}
|
||||
fetchReleaseInfo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const releasesInfoUrl = 'https://tencent.github.io/konajdk/releases/kona-v1.json';
|
||||
try {
|
||||
core.debug(`Fetching Kona release info from URL: ${releasesInfoUrl}`);
|
||||
return (yield this.http.getJson(releasesInfoUrl))
|
||||
.result;
|
||||
}
|
||||
catch (err) {
|
||||
core.debug(`Fetching Kona release info from the URL: ${releasesInfoUrl} failed with the error: ${err.message}`);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
chooseReleases(os, arch, releaseInfo) {
|
||||
const releases = [];
|
||||
for (const majorVersion in releaseInfo) {
|
||||
const versions = releaseInfo[majorVersion];
|
||||
for (const version of versions) {
|
||||
if (!version.latest) {
|
||||
continue;
|
||||
}
|
||||
for (const file of version.files) {
|
||||
if (file.os === os && file.arch === arch) {
|
||||
releases.push({
|
||||
version: version.version,
|
||||
jdkVersion: version.jdkVersion,
|
||||
os: os,
|
||||
arch: arch,
|
||||
downloadUrl: version.baseUrl + file.filename,
|
||||
checksum: file.checksum
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return releases;
|
||||
}
|
||||
getOs() {
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return 'macos';
|
||||
case 'win32':
|
||||
return 'windows';
|
||||
default:
|
||||
return process.platform;
|
||||
}
|
||||
}
|
||||
getArch() {
|
||||
switch (this.architecture) {
|
||||
case 'arm64':
|
||||
return 'aarch64';
|
||||
case 'x64':
|
||||
return 'x86_64';
|
||||
default:
|
||||
return this.architecture;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.KonaDistribution = KonaDistribution;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 32063:
|
||||
|
||||
Reference in New Issue
Block a user