mirror of
https://github.com/actions/setup-java.git
synced 2026-06-24 08:31:02 +03:00
Merge branch 'main' into copilot/disable-interactivemode-settings-xml
This commit is contained in:
Vendored
+142
-24
@@ -78772,6 +78772,7 @@ var JavaDistribution;
|
||||
JavaDistribution["Dragonwell"] = "dragonwell";
|
||||
JavaDistribution["SapMachine"] = "sapmachine";
|
||||
JavaDistribution["GraalVM"] = "graalvm";
|
||||
JavaDistribution["GraalVMCommunity"] = "graalvm-community";
|
||||
JavaDistribution["JetBrains"] = "jetbrains";
|
||||
})(JavaDistribution || (JavaDistribution = {}));
|
||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
@@ -78803,6 +78804,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
return new installer_11.SapMachineDistribution(installerOptions);
|
||||
case JavaDistribution.GraalVM:
|
||||
return new installer_12.GraalVMDistribution(installerOptions);
|
||||
case JavaDistribution.GraalVMCommunity:
|
||||
return new installer_12.GraalVMCommunityDistribution(installerOptions);
|
||||
case JavaDistribution.JetBrains:
|
||||
return new installer_13.JetBrainsDistribution(installerOptions);
|
||||
default:
|
||||
@@ -79070,23 +79073,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.GraalVMDistribution = void 0;
|
||||
exports.GraalVMCommunityDistribution = exports.GraalVMDistribution = void 0;
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const tc = __importStar(__nccwpck_require__(33472));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(79896));
|
||||
const path_1 = __importDefault(__nccwpck_require__(16928));
|
||||
const semver_1 = __importDefault(__nccwpck_require__(62088));
|
||||
const base_installer_1 = __nccwpck_require__(79935);
|
||||
const http_client_1 = __nccwpck_require__(54844);
|
||||
const util_1 = __nccwpck_require__(54527);
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
||||
const GRAALVM_COMMUNITY_RELEASES_URL = 'https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=100';
|
||||
const GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN = 'https://api.github.com';
|
||||
const GRAALVM_COMMUNITY_DOWNLOAD_URL = 'https://github.com/graalvm/graalvm-ce-builds/releases';
|
||||
const GRAALVM_COMMUNITY_ASSET_PREFIX = 'graalvm-community-jdk-';
|
||||
const GRAALVM_COMMUNITY_VERSION_PATTERN = /^\d+(?:\.\d+)*$/;
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||
const GRAALVM_MIN_VERSION = 17;
|
||||
const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'];
|
||||
class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
constructor(installerOptions) {
|
||||
super('GraalVM', installerOptions);
|
||||
constructor(installerOptions, distributionName = 'GraalVM') {
|
||||
super(distributionName, installerOptions);
|
||||
}
|
||||
downloadTool(javaRelease) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
@@ -79120,36 +79129,50 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
}
|
||||
findPackageForDownload(range) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Add input validation
|
||||
if (!range || typeof range !== 'string') {
|
||||
throw new Error('Version range is required and must be a string');
|
||||
}
|
||||
const arch = this.distributionArchitecture();
|
||||
if (!SUPPORTED_ARCHITECTURES.includes(arch)) {
|
||||
throw new Error(`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`);
|
||||
}
|
||||
this.validateVersionRange(range);
|
||||
const arch = this.getSupportedArchitecture();
|
||||
if (!this.stable) {
|
||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||
}
|
||||
if (this.packageType !== 'jdk') {
|
||||
throw new Error('GraalVM provides only the `jdk` package type');
|
||||
}
|
||||
const platform = this.getPlatform();
|
||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||
const major = range.includes('.') ? range.split('.')[0] : range;
|
||||
const majorVersion = parseInt(major);
|
||||
if (isNaN(majorVersion)) {
|
||||
throw new Error(`Invalid version format: ${range}`);
|
||||
}
|
||||
if (majorVersion < GRAALVM_MIN_VERSION) {
|
||||
throw new Error(`GraalVM is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`);
|
||||
}
|
||||
const { platform, extension, major } = this.validateStableBuildRequest(range);
|
||||
const fileUrl = this.constructFileUrl(range, major, platform, arch, extension);
|
||||
const response = yield this.http.head(fileUrl);
|
||||
this.handleHttpResponse(response, range);
|
||||
return { url: fileUrl, version: range };
|
||||
});
|
||||
}
|
||||
validateVersionRange(range) {
|
||||
if (!range || typeof range !== 'string') {
|
||||
throw new Error('Version range is required and must be a string');
|
||||
}
|
||||
}
|
||||
getSupportedArchitecture() {
|
||||
const arch = this.distributionArchitecture();
|
||||
if (!SUPPORTED_ARCHITECTURES.includes(arch)) {
|
||||
throw new Error(`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`);
|
||||
}
|
||||
return arch;
|
||||
}
|
||||
validateStableBuildRequest(range) {
|
||||
if (this.packageType !== 'jdk') {
|
||||
throw new Error(`${this.distribution} provides only the \`jdk\` package type`);
|
||||
}
|
||||
const platform = this.getPlatform();
|
||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||
const major = range.includes('.') ? range.split('.')[0] : range;
|
||||
const majorVersion = parseInt(major);
|
||||
if (isNaN(majorVersion)) {
|
||||
throw new Error(`Invalid version format: ${range}`);
|
||||
}
|
||||
if (majorVersion < GRAALVM_MIN_VERSION) {
|
||||
throw new Error(`${this.distribution} is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`);
|
||||
}
|
||||
return {
|
||||
platform,
|
||||
major,
|
||||
extension
|
||||
};
|
||||
}
|
||||
constructFileUrl(range, major, platform, arch, extension) {
|
||||
return range.includes('.')
|
||||
? `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`
|
||||
@@ -79240,6 +79263,101 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
}
|
||||
}
|
||||
exports.GraalVMDistribution = GraalVMDistribution;
|
||||
class GraalVMCommunityDistribution extends GraalVMDistribution {
|
||||
constructor(installerOptions) {
|
||||
super(installerOptions, 'GraalVM Community');
|
||||
}
|
||||
get toolcacheFolderName() {
|
||||
return `Java_GraalVM_Community_${this.packageType}`;
|
||||
}
|
||||
findPackageForDownload(range) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.validateVersionRange(range);
|
||||
if (!this.stable) {
|
||||
throw new Error('GraalVM Community does not provide early access builds');
|
||||
}
|
||||
const arch = this.getSupportedArchitecture();
|
||||
const { platform, extension } = this.validateStableBuildRequest(range);
|
||||
// GraalVM Community asset names embed the platform, architecture and
|
||||
// archive type, e.g. `graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz`.
|
||||
const assetSuffix = `_${platform}-${arch}_bin.${extension}`;
|
||||
const availableVersions = yield this.getAvailableVersions(assetSuffix);
|
||||
const satisfiedVersion = availableVersions
|
||||
.filter(item => (0, util_1.isVersionSatisfies)(range, item.version))
|
||||
.sort((a, b) => -semver_1.default.compareBuild(a.version, b.version))[0];
|
||||
if (!satisfiedVersion) {
|
||||
const error = this.createVersionNotFoundError(range, availableVersions.map(item => item.version), `Platform: ${platform}`);
|
||||
error.message += `\nPlease check if this version is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`;
|
||||
throw error;
|
||||
}
|
||||
return satisfiedVersion;
|
||||
});
|
||||
}
|
||||
getAvailableVersions(assetSuffix) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const headers = (0, util_1.getGitHubHttpHeaders)();
|
||||
const versions = new Map();
|
||||
let releasesUrl = GRAALVM_COMMUNITY_RELEASES_URL;
|
||||
for (let pageIndex = 0; releasesUrl && pageIndex < util_1.MAX_PAGINATION_PAGES; pageIndex++) {
|
||||
const response = yield this.http.getJson(releasesUrl, headers);
|
||||
// A successful GitHub releases listing is always a JSON array (possibly
|
||||
// empty). Anything else indicates an unexpected/error payload (rate
|
||||
// limiting, auth failure, etc.) that must be surfaced instead of being
|
||||
// silently treated as "no releases", which would later look like a
|
||||
// misleading "version not found" error.
|
||||
if (!Array.isArray(response.result)) {
|
||||
throw new Error(`Unexpected response while listing GraalVM Community releases from ${releasesUrl} ` +
|
||||
`(HTTP status code: ${response.statusCode}). Expected a JSON array of releases. ` +
|
||||
`Please check if the service is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`);
|
||||
}
|
||||
const releases = response.result;
|
||||
if (releases.length === 0) {
|
||||
break;
|
||||
}
|
||||
for (const release of releases) {
|
||||
if (release.draft || release.prerelease) {
|
||||
continue;
|
||||
}
|
||||
for (const asset of (_a = release.assets) !== null && _a !== void 0 ? _a : []) {
|
||||
const version = this.extractAssetVersion(asset.name, assetSuffix);
|
||||
if (version) {
|
||||
versions.set(version, {
|
||||
version,
|
||||
url: asset.browser_download_url
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
releasesUrl = this.getNextReleasesUrl(response.headers);
|
||||
}
|
||||
return [...versions.values()];
|
||||
});
|
||||
}
|
||||
// Returns the GraalVM JDK version encoded in a release asset name when it
|
||||
// matches the requested platform/architecture/archive suffix, otherwise null.
|
||||
extractAssetVersion(assetName, assetSuffix) {
|
||||
if (!assetName.startsWith(GRAALVM_COMMUNITY_ASSET_PREFIX) ||
|
||||
!assetName.endsWith(assetSuffix)) {
|
||||
return null;
|
||||
}
|
||||
const rawVersion = assetName.slice(GRAALVM_COMMUNITY_ASSET_PREFIX.length, -assetSuffix.length);
|
||||
if (!GRAALVM_COMMUNITY_VERSION_PATTERN.test(rawVersion)) {
|
||||
return null;
|
||||
}
|
||||
return (0, util_1.convertVersionToSemver)(rawVersion);
|
||||
}
|
||||
getNextReleasesUrl(headers) {
|
||||
const nextUrl = (0, util_1.getNextPageUrlFromLinkHeader)(headers);
|
||||
if (nextUrl &&
|
||||
!(0, util_1.validatePaginationUrl)(nextUrl, GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN)) {
|
||||
core.warning(`Ignoring pagination link with unexpected origin: ${nextUrl}`);
|
||||
return null;
|
||||
}
|
||||
return nextUrl;
|
||||
}
|
||||
}
|
||||
exports.GraalVMCommunityDistribution = GraalVMCommunityDistribution;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
Reference in New Issue
Block a user