mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 09:56:46 +00:00
Fix formatting of oracle/installer.ts
This commit is contained in:
parent
5c6f90ed9a
commit
46d790322c
1 changed files with 13 additions and 11 deletions
|
@ -9,7 +9,7 @@ import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from
|
||||||
import { extractJdkFile, getDownloadArchiveExtension } from '../../util';
|
import { extractJdkFile, getDownloadArchiveExtension } from '../../util';
|
||||||
import { HttpCodes } from '@actions/http-client';
|
import { HttpCodes } from '@actions/http-client';
|
||||||
|
|
||||||
const ORACLE_DL_BASE = 'https://download.oracle.com/java'
|
const ORACLE_DL_BASE = 'https://download.oracle.com/java';
|
||||||
|
|
||||||
export class OracleDistribution extends JavaBase {
|
export class OracleDistribution extends JavaBase {
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
|
@ -55,33 +55,35 @@ export class OracleDistribution extends JavaBase {
|
||||||
throw new Error('Oracle JDK provides only the `jdk` package type');
|
throw new Error('Oracle JDK provides only the `jdk` package type');
|
||||||
}
|
}
|
||||||
|
|
||||||
const platform = this.getPlatform()
|
const platform = this.getPlatform();
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
let major;
|
let major;
|
||||||
let fileUrl;
|
let fileUrl;
|
||||||
if (range.includes('.')) {
|
if (range.includes('.')) {
|
||||||
major = range.split('.')[0]
|
major = range.split('.')[0];
|
||||||
fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`
|
fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||||
} else {
|
} else {
|
||||||
major = range
|
major = range;
|
||||||
fileUrl = `${ORACLE_DL_BASE}/${range}/latest/jdk-${range}_${platform}-${arch}_bin.${extension}`
|
fileUrl = `${ORACLE_DL_BASE}/${range}/latest/jdk-${range}_${platform}-${arch}_bin.${extension}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(major) < 17) {
|
if (parseInt(major) < 17) {
|
||||||
throw new Error('Oracle JDK is only supported for JDK 17 and later')
|
throw new Error('Oracle JDK is only supported for JDK 17 and later');
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.http.head(fileUrl)
|
const response = await this.http.head(fileUrl);
|
||||||
|
|
||||||
if (response.message.statusCode === HttpCodes.NotFound) {
|
if (response.message.statusCode === HttpCodes.NotFound) {
|
||||||
throw new Error(`Could not find Oracle JDK for SemVer ${range}`);
|
throw new Error(`Could not find Oracle JDK for SemVer ${range}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.message.statusCode !== HttpCodes.OK) {
|
if (response.message.statusCode !== HttpCodes.OK) {
|
||||||
throw new Error(`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`);
|
throw new Error(
|
||||||
|
`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { url: fileUrl, version: range }
|
return { url: fileUrl, version: range };
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {
|
private getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue