mirror of
https://github.com/actions/setup-java.git
synced 2026-07-28 15:14:30 +02:00
Support archived OpenJDK release formats
This commit is contained in:
Vendored
+18
-13
@@ -131909,8 +131909,8 @@ class OpenJdkDistribution extends JavaBase {
|
||||
info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||
let javaArchivePath = await downloadTool(javaRelease.url);
|
||||
info(`Extracting Java archive...`);
|
||||
const extension = getDownloadArchiveExtension();
|
||||
if (process.platform === 'win32') {
|
||||
const extension = javaRelease.url.endsWith('.zip') ? 'zip' : 'tar.gz';
|
||||
if (extension === 'zip') {
|
||||
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||
}
|
||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||
@@ -131934,18 +131934,23 @@ class OpenJdkDistribution extends JavaBase {
|
||||
return response.readBody();
|
||||
}
|
||||
parseReleases(html, platform, arch) {
|
||||
const extension = platform === 'windows' ? 'zip' : 'tar.gz';
|
||||
const pattern = new RegExp(`href="(https://download\\.java\\.net/[^"]+/openjdk-([^"_]+)_${platform}-${arch}_bin\\.${extension.replaceAll('.', '\\.')})"`, 'g');
|
||||
return Array.from(html.matchAll(pattern), match => ({
|
||||
version: this.toSemver(match[2]),
|
||||
url: match[1]
|
||||
}));
|
||||
const platformPattern = platform === 'macos' ? '(?:macos|osx)' : platform;
|
||||
const extensionPattern = platform === 'windows' ? '(?:zip|tar\\.gz)' : 'tar\\.gz';
|
||||
const pattern = new RegExp(`href="(https://download\\.java\\.net/[^"]+/openjdk-([^"_]+)_${platformPattern}-${arch}_bin\\.${extensionPattern})"`, 'g');
|
||||
return Array.from(html.matchAll(pattern), match => {
|
||||
const url = match[1];
|
||||
const build = url.match(/\/(\d+)\/GPL\/openjdk-/)?.[1];
|
||||
return {
|
||||
version: this.toSemver(match[2], build),
|
||||
url
|
||||
};
|
||||
});
|
||||
}
|
||||
toSemver(version) {
|
||||
const [javaVersion, build] = version.replace('-ea', '').split('+');
|
||||
const normalizedVersion = javaVersion.includes('.')
|
||||
? javaVersion
|
||||
: `${javaVersion}.0.0`;
|
||||
toSemver(version, urlBuild) {
|
||||
const [javaVersion, filenameBuild] = version.replace('-ea', '').split('+');
|
||||
const versionParts = javaVersion.split('.');
|
||||
const normalizedVersion = convertVersionToSemver(versionParts.length === 1 ? `${javaVersion}.0.0` : javaVersion);
|
||||
const build = filenameBuild ?? (versionParts.length <= 3 ? urlBuild : undefined);
|
||||
return build ? `${normalizedVersion}+${build}` : normalizedVersion;
|
||||
}
|
||||
getPlatform(platform = process.platform) {
|
||||
|
||||
Reference in New Issue
Block a user