mirror of
https://github.com/actions/setup-java.git
synced 2026-07-29 21:16:26 +00:00
Add force-download option for reproducible JDK builds (#1148)
* Initial plan * Add force-download input * Build force-download action bundles --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Bruno Borges <brborges@microsoft.com>
This commit is contained in:
@@ -7,6 +7,7 @@ export const INPUT_DISTRIBUTION = 'distribution';
|
||||
export const INPUT_JDK_FILE = 'jdk-file';
|
||||
export const INPUT_JDK_FILE_DEPRECATED = 'jdkFile';
|
||||
export const INPUT_CHECK_LATEST = 'check-latest';
|
||||
export const INPUT_FORCE_DOWNLOAD = 'force-download';
|
||||
export const INPUT_SET_DEFAULT = 'set-default';
|
||||
export const INPUT_PROBLEM_MATCHER = 'problem-matcher';
|
||||
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||
|
||||
@@ -25,6 +25,7 @@ export abstract class JavaBase {
|
||||
protected stable: boolean;
|
||||
protected latest: boolean;
|
||||
protected checkLatest: boolean;
|
||||
protected forceDownload: boolean;
|
||||
protected setDefault: boolean;
|
||||
protected verifySignature: boolean;
|
||||
protected verifySignaturePublicKey: string | undefined;
|
||||
@@ -46,6 +47,7 @@ export abstract class JavaBase {
|
||||
this.architecture = installerOptions.architecture || os.arch();
|
||||
this.packageType = installerOptions.packageType;
|
||||
this.checkLatest = installerOptions.checkLatest;
|
||||
this.forceDownload = installerOptions.forceDownload ?? false;
|
||||
this.setDefault =
|
||||
installerOptions.setDefault !== undefined
|
||||
? installerOptions.setDefault
|
||||
@@ -68,7 +70,7 @@ export abstract class JavaBase {
|
||||
);
|
||||
}
|
||||
|
||||
let foundJava = this.findInToolcache();
|
||||
let foundJava = this.forceDownload ? null : this.findInToolcache();
|
||||
if (foundJava && !this.checkLatest && !this.latest) {
|
||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||
} else {
|
||||
@@ -91,7 +93,10 @@ export abstract class JavaBase {
|
||||
}
|
||||
const javaRelease = await this.findPackageForDownload(this.version);
|
||||
core.info(`Resolved latest version as ${javaRelease.version}`);
|
||||
if (foundJava?.version === javaRelease.version) {
|
||||
if (
|
||||
!this.forceDownload &&
|
||||
foundJava?.version === javaRelease.version
|
||||
) {
|
||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||
} else {
|
||||
core.info('Trying to download...');
|
||||
|
||||
@@ -3,6 +3,7 @@ export interface JavaInstallerOptions {
|
||||
architecture: string;
|
||||
packageType: string;
|
||||
checkLatest: boolean;
|
||||
forceDownload?: boolean;
|
||||
setDefault?: boolean;
|
||||
verifySignature?: boolean;
|
||||
verifySignaturePublicKey?: string;
|
||||
|
||||
@@ -28,7 +28,7 @@ export class LocalDistribution extends JavaBase {
|
||||
);
|
||||
}
|
||||
|
||||
let foundJava = this.findInToolcache();
|
||||
let foundJava = this.forceDownload ? null : this.findInToolcache();
|
||||
|
||||
if (foundJava) {
|
||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||
|
||||
@@ -29,6 +29,10 @@ async function run() {
|
||||
constants.INPUT_CACHE_DEPENDENCY_PATH
|
||||
);
|
||||
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||
const forceDownload = getBooleanInput(
|
||||
constants.INPUT_FORCE_DOWNLOAD,
|
||||
false
|
||||
);
|
||||
const setDefault = getBooleanInput(constants.INPUT_SET_DEFAULT, true);
|
||||
const verifySignature = getBooleanInput(
|
||||
constants.INPUT_VERIFY_SIGNATURE,
|
||||
@@ -83,6 +87,7 @@ async function run() {
|
||||
architecture,
|
||||
packageType,
|
||||
checkLatest,
|
||||
forceDownload,
|
||||
setDefault,
|
||||
verifySignature,
|
||||
verifySignaturePublicKey,
|
||||
@@ -102,6 +107,7 @@ async function run() {
|
||||
architecture,
|
||||
packageType,
|
||||
checkLatest,
|
||||
forceDownload,
|
||||
setDefault,
|
||||
verifySignature,
|
||||
verifySignaturePublicKey,
|
||||
@@ -159,6 +165,7 @@ async function installVersion(
|
||||
architecture,
|
||||
packageType,
|
||||
checkLatest,
|
||||
forceDownload,
|
||||
setDefault,
|
||||
verifySignature,
|
||||
verifySignaturePublicKey,
|
||||
@@ -169,6 +176,7 @@ async function installVersion(
|
||||
architecture,
|
||||
packageType,
|
||||
checkLatest,
|
||||
forceDownload,
|
||||
setDefault,
|
||||
verifySignature,
|
||||
verifySignaturePublicKey,
|
||||
@@ -212,6 +220,7 @@ interface installerInputsOptions {
|
||||
architecture: string;
|
||||
packageType: string;
|
||||
checkLatest: boolean;
|
||||
forceDownload: boolean;
|
||||
setDefault: boolean;
|
||||
verifySignature: boolean;
|
||||
verifySignaturePublicKey: string | undefined;
|
||||
|
||||
Reference in New Issue
Block a user