mirror of
https://github.com/actions/setup-java.git
synced 2025-03-13 09:37:03 +00:00
eliminate duplication in version numbers
This commit is contained in:
parent
bf48000b8b
commit
ef8955b635
3 changed files with 28 additions and 44 deletions
34
dist/setup/index.js
vendored
34
dist/setup/index.js
vendored
|
@ -13864,7 +13864,6 @@ const core = __importStar(__webpack_require__(470));
|
||||||
const tc = __importStar(__webpack_require__(139));
|
const tc = __importStar(__webpack_require__(139));
|
||||||
const fs_1 = __importDefault(__webpack_require__(747));
|
const fs_1 = __importDefault(__webpack_require__(747));
|
||||||
const path_1 = __importDefault(__webpack_require__(622));
|
const path_1 = __importDefault(__webpack_require__(622));
|
||||||
const supportedPlatform = `'linux', 'macos', 'windows'`;
|
|
||||||
class MicrosoftDistributions extends base_installer_1.JavaBase {
|
class MicrosoftDistributions extends base_installer_1.JavaBase {
|
||||||
constructor(installerOptions) {
|
constructor(installerOptions) {
|
||||||
super('Microsoft', installerOptions);
|
super('Microsoft', installerOptions);
|
||||||
|
@ -13884,13 +13883,13 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
|
||||||
}
|
}
|
||||||
findPackageForDownload(range) {
|
findPackageForDownload(range) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (this.architecture !== 'x64' && this.architecture != 'aarch64') {
|
if (this.architecture !== 'x64' && this.architecture !== 'aarch64') {
|
||||||
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
||||||
}
|
}
|
||||||
const availableVersionsRaw = yield this.getAvailableVersions();
|
const availableVersionsRaw = yield this.getAvailableVersions();
|
||||||
const opts = this.getPlatformOption();
|
const opts = this.getPlatformOption();
|
||||||
const availableVersions = availableVersionsRaw.map(item => ({
|
const availableVersions = availableVersionsRaw.map(item => ({
|
||||||
url: `https://aka.ms/download-jdk/microsoft-jdk-${item.fullVersion.join('.')}-${opts.os}-${this.architecture}.${opts.archive}`,
|
url: `https://aka.ms/download-jdk/microsoft-jdk-${item.version.join('.')}-${opts.os}-${this.architecture}.${opts.archive}`,
|
||||||
version: this.convertVersionToSemver(item)
|
version: this.convertVersionToSemver(item)
|
||||||
}));
|
}));
|
||||||
const satisfiedVersion = availableVersions
|
const satisfiedVersion = availableVersions
|
||||||
|
@ -13909,34 +13908,26 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
|
||||||
getAvailableVersions() {
|
getAvailableVersions() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// TODO get these dynamically!
|
// TODO get these dynamically!
|
||||||
|
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||||
const jdkVersions = [
|
const jdkVersions = [
|
||||||
{
|
{
|
||||||
majorVersion: 17,
|
version: [17, 0, 1, 12, 1]
|
||||||
minorVersion: 0,
|
|
||||||
patchVersion: 1,
|
|
||||||
fullVersion: [17, 0, 1, 12, 1],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
majorVersion: 16,
|
version: [16, 0, 2, 7, 1]
|
||||||
minorVersion: 0,
|
}
|
||||||
patchVersion: 2,
|
|
||||||
fullVersion: [16, 0, 2.7, 1],
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
// M1 is only supported for Java 16 & 17
|
// M1 is only supported for Java 16 & 17
|
||||||
if (process.platform !== 'darwin' || this.architecture !== 'aarch64') {
|
if (process.platform !== 'darwin' || this.architecture !== 'aarch64') {
|
||||||
jdkVersions.push({
|
jdkVersions.push({
|
||||||
majorVersion: 11,
|
version: [11, 0, 13, 8, 1]
|
||||||
minorVersion: 0,
|
|
||||||
patchVersion: 13,
|
|
||||||
fullVersion: [11, 0, 13, 8, 1],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return jdkVersions;
|
return jdkVersions;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getPlatformOption(platform = process.platform) {
|
getPlatformOption() {
|
||||||
switch (platform) {
|
switch (process.platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return { archive: 'tar.gz', os: 'macos' };
|
return { archive: 'tar.gz', os: 'macos' };
|
||||||
case 'win32':
|
case 'win32':
|
||||||
|
@ -13944,11 +13935,14 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return { archive: 'tar.gz', os: 'linux' };
|
return { archive: 'tar.gz', os: 'linux' };
|
||||||
default:
|
default:
|
||||||
throw new Error(`Platform '${platform}' is not supported. Supported platforms: ${supportedPlatform}`);
|
throw new Error(`Platform '${process.platform}' is not supported. Supported platforms: 'darwin', 'linux', 'win32'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
convertVersionToSemver(version) {
|
convertVersionToSemver(version) {
|
||||||
return `${version.majorVersion}.${version.minorVersion}.${version.patchVersion}`;
|
const major = version.version[0];
|
||||||
|
const minor = version.version[1];
|
||||||
|
const patch = version.version[2];
|
||||||
|
return `${major}.${minor}.${patch}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.MicrosoftDistributions = MicrosoftDistributions;
|
exports.MicrosoftDistributions = MicrosoftDistributions;
|
||||||
|
|
|
@ -8,8 +8,6 @@ import * as tc from '@actions/tool-cache';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
const supportedPlatform = `'linux', 'macos', 'windows'`;
|
|
||||||
|
|
||||||
export class MicrosoftDistributions extends JavaBase {
|
export class MicrosoftDistributions extends JavaBase {
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
super('Microsoft', installerOptions);
|
super('Microsoft', installerOptions);
|
||||||
|
@ -39,14 +37,14 @@ export class MicrosoftDistributions extends JavaBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async findPackageForDownload(range: string): Promise<JavaDownloadRelease> {
|
protected async findPackageForDownload(range: string): Promise<JavaDownloadRelease> {
|
||||||
if (this.architecture !== 'x64' && this.architecture != 'aarch64') {
|
if (this.architecture !== 'x64' && this.architecture !== 'aarch64') {
|
||||||
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
||||||
}
|
}
|
||||||
const availableVersionsRaw = await this.getAvailableVersions();
|
const availableVersionsRaw = await this.getAvailableVersions();
|
||||||
|
|
||||||
const opts = this.getPlatformOption();
|
const opts = this.getPlatformOption();
|
||||||
const availableVersions = availableVersionsRaw.map(item => ({
|
const availableVersions = availableVersionsRaw.map(item => ({
|
||||||
url: `https://aka.ms/download-jdk/microsoft-jdk-${item.fullVersion.join('.')}-${opts.os}-${
|
url: `https://aka.ms/download-jdk/microsoft-jdk-${item.version.join('.')}-${opts.os}-${
|
||||||
this.architecture
|
this.architecture
|
||||||
}.${opts.archive}`,
|
}.${opts.archive}`,
|
||||||
version: this.convertVersionToSemver(item)
|
version: this.convertVersionToSemver(item)
|
||||||
|
@ -71,36 +69,28 @@ export class MicrosoftDistributions extends JavaBase {
|
||||||
|
|
||||||
private async getAvailableVersions(): Promise<MicrosoftVersion[]> {
|
private async getAvailableVersions(): Promise<MicrosoftVersion[]> {
|
||||||
// TODO get these dynamically!
|
// TODO get these dynamically!
|
||||||
|
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||||
const jdkVersions = [
|
const jdkVersions = [
|
||||||
{
|
{
|
||||||
majorVersion: 17,
|
version: [17, 0, 1, 12, 1]
|
||||||
minorVersion: 0,
|
|
||||||
patchVersion: 1,
|
|
||||||
fullVersion: [17, 0, 1, 12, 1]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
majorVersion: 16,
|
version: [16, 0, 2, 7, 1]
|
||||||
minorVersion: 0,
|
|
||||||
patchVersion: 2,
|
|
||||||
fullVersion: [16, 0, 2.7, 1]
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// M1 is only supported for Java 16 & 17
|
// M1 is only supported for Java 16 & 17
|
||||||
if (process.platform !== 'darwin' || this.architecture !== 'aarch64') {
|
if (process.platform !== 'darwin' || this.architecture !== 'aarch64') {
|
||||||
jdkVersions.push({
|
jdkVersions.push({
|
||||||
majorVersion: 11,
|
version: [11, 0, 13, 8, 1]
|
||||||
minorVersion: 0,
|
|
||||||
patchVersion: 13,
|
|
||||||
fullVersion: [11, 0, 13, 8, 1]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return jdkVersions;
|
return jdkVersions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPlatformOption(platform: NodeJS.Platform = process.platform): PlatformOptions {
|
private getPlatformOption(): PlatformOptions {
|
||||||
switch (platform) {
|
switch (process.platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return { archive: 'tar.gz', os: 'macos' };
|
return { archive: 'tar.gz', os: 'macos' };
|
||||||
case 'win32':
|
case 'win32':
|
||||||
|
@ -109,12 +99,15 @@ export class MicrosoftDistributions extends JavaBase {
|
||||||
return { archive: 'tar.gz', os: 'linux' };
|
return { archive: 'tar.gz', os: 'linux' };
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Platform '${platform}' is not supported. Supported platforms: ${supportedPlatform}`
|
`Platform '${process.platform}' is not supported. Supported platforms: 'darwin', 'linux', 'win32'`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private convertVersionToSemver(version: MicrosoftVersion): string {
|
private convertVersionToSemver(version: MicrosoftVersion): string {
|
||||||
return `${version.majorVersion}.${version.minorVersion}.${version.patchVersion}`;
|
const major = version.version[0];
|
||||||
|
const minor = version.version[1];
|
||||||
|
const patch = version.version[2];
|
||||||
|
return `${major}.${minor}.${patch}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,5 @@ export interface PlatformOptions {
|
||||||
|
|
||||||
export interface MicrosoftVersion {
|
export interface MicrosoftVersion {
|
||||||
downloadUrl?: string;
|
downloadUrl?: string;
|
||||||
majorVersion: number;
|
version: Array<number>;
|
||||||
minorVersion: number;
|
|
||||||
patchVersion: number;
|
|
||||||
fullVersion: Array<number>;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue