mirror of
https://github.com/actions/setup-java.git
synced 2025-06-29 12:34:14 +00:00
add changes for check-latest
This commit is contained in:
parent
804a60faf9
commit
8f3a7c87ff
9 changed files with 3363 additions and 9258 deletions
|
@ -4,6 +4,7 @@ export const INPUT_ARCHITECTURE = 'architecture';
|
|||
export const INPUT_JAVA_PACKAGE = 'java-package';
|
||||
export const INPUT_DISTRIBUTION = 'distribution';
|
||||
export const INPUT_JDK_FILE = 'jdkFile';
|
||||
export const INPUT_CHECK_LATEST = 'check-latest';
|
||||
export const INPUT_SERVER_ID = 'server-id';
|
||||
export const INPUT_SERVER_USERNAME = 'server-username';
|
||||
export const INPUT_SERVER_PASSWORD = 'server-password';
|
||||
|
|
|
@ -12,6 +12,7 @@ export abstract class JavaBase {
|
|||
protected architecture: string;
|
||||
protected packageType: string;
|
||||
protected stable: boolean;
|
||||
protected checkLatest: boolean;
|
||||
|
||||
constructor(protected distribution: string, installerOptions: JavaInstallerOptions) {
|
||||
this.http = new httpm.HttpClient('actions/setup-java', undefined, {
|
||||
|
@ -24,6 +25,7 @@ export abstract class JavaBase {
|
|||
));
|
||||
this.architecture = installerOptions.architecture;
|
||||
this.packageType = installerOptions.packageType;
|
||||
this.checkLatest = !!installerOptions.checkLatest;
|
||||
}
|
||||
|
||||
protected abstract downloadTool(javaRelease: JavaDownloadRelease): Promise<JavaInstallerResults>;
|
||||
|
@ -31,13 +33,17 @@ export abstract class JavaBase {
|
|||
|
||||
public async setupJava(): Promise<JavaInstallerResults> {
|
||||
let foundJava = this.findInToolcache();
|
||||
if (foundJava) {
|
||||
if (foundJava && !this.checkLatest) {
|
||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||
} else {
|
||||
core.info(`Java ${this.version} was not found in tool-cache. Trying to download...`);
|
||||
const javaRelease = await this.findPackageForDownload(this.version);
|
||||
foundJava = await this.downloadTool(javaRelease);
|
||||
core.info(`Java ${foundJava.version} was downloaded`);
|
||||
if (foundJava?.version != javaRelease.version) {
|
||||
foundJava = await this.downloadTool(javaRelease);
|
||||
core.info(`Java ${foundJava.version} was downloaded`);
|
||||
}
|
||||
|
||||
core.info(`Java ${foundJava.version} was resolved`);
|
||||
}
|
||||
|
||||
core.info(`Setting Java ${foundJava.version} as the default`);
|
||||
|
|
|
@ -2,6 +2,7 @@ export interface JavaInstallerOptions {
|
|||
version: string;
|
||||
architecture: string;
|
||||
packageType: string;
|
||||
checkLatest?: boolean;
|
||||
}
|
||||
|
||||
export interface JavaInstallerResults {
|
||||
|
|
|
@ -13,11 +13,13 @@ async function run() {
|
|||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
||||
const checkLatest = core.getInput(constants.INPUT_CHECK_LATEST);
|
||||
|
||||
const installerOptions: JavaInstallerOptions = {
|
||||
architecture,
|
||||
packageType,
|
||||
version
|
||||
version,
|
||||
checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true'
|
||||
};
|
||||
|
||||
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue