mirror of
https://github.com/actions/setup-java.git
synced 2026-08-06 17:12:58 +00:00
Add conditional JDK caching (#1201)
* Add JDK caching Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Apply batched suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Fix JDK cache CI validation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Update brace-expansion security fix Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Refresh brace-expansion license metadata Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Refine JDK cache semantics Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Refine JDK cache documentation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Simplify JDK cache identity Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Align JDK cache OS identity Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Harden JDK cache saves and document tool-cache reuse Bind each JDK cache key to the installation identity it was computed for, keep post-job saves best-effort per entry, and state the real reuse and verification guarantee in the documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * docs: restructure README caching section Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached overview table covering the dependency, wrapper, and JDK caches. Lead with the common 'cache: maven' example and the dependency-cache material, and demote JDK caching into its own subsection. Also corrects the IMPORTANT callout, which implied JDK caching required an explicit opt-in; it is enabled implicitly whenever 'cache' is set. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * docs: fix caching documentation defects - Remove pull-request framing that compared behavior to `main`; state the tool-cache and `jdkfile` behavior directly and unconditionally. - Clarify that the JDK cache is a separate cache *entry* from the dependency and wrapper caches, while its *enablement* is coupled to `cache`, so the opening paragraph agrees with the enablement matrix. - Cite the actions/setup-java-benchmarks repository instead of an open PR and a self-referential PR comment, keeping the measured figures and caveats. - Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and summarize the rules in prose in README.md to avoid divergence. - Describe the guarantee that a cache key is only saved with the installation it was computed for, instead of documenting inode/size/timestamp internals. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * docs: add V6 what's new entry for JDK caching Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
This commit is contained in:
Vendored
+15
-2
@@ -30770,6 +30770,7 @@ module.exports = {
|
||||
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ At: () => (/* binding */ INPUT_CACHE_DEPENDENCY_PATH),
|
||||
/* harmony export */ E8: () => (/* binding */ INPUT_SET_DEFAULT),
|
||||
/* harmony export */ GL: () => (/* binding */ INPUT_CACHE_JDK),
|
||||
/* harmony export */ I9: () => (/* binding */ INPUT_FORCE_DOWNLOAD),
|
||||
/* harmony export */ K$: () => (/* binding */ GPG_PASSPHRASE_PROFILE_ID),
|
||||
/* harmony export */ LS: () => (/* binding */ INPUT_ARCHITECTURE),
|
||||
@@ -30849,6 +30850,7 @@ const MAVEN_GPG_PASSPHRASE_DEFAULT_ENV = 'MAVEN_GPG_PASSPHRASE';
|
||||
// Id of the settings.xml profile used to set `gpg.passphraseEnvName`.
|
||||
const GPG_PASSPHRASE_PROFILE_ID = 'setup-java-gpg';
|
||||
const INPUT_CACHE = 'cache';
|
||||
const INPUT_CACHE_JDK = 'cache-jdk';
|
||||
const INPUT_CACHE_DEPENDENCY_PATH = 'cache-dependency-path';
|
||||
const INPUT_CACHE_PATH = 'cache-path';
|
||||
const INPUT_CACHE_READ_ONLY = 'cache-read-only';
|
||||
@@ -31243,6 +31245,7 @@ function validateToolchainIds(versions, versionFile, toolchainIds) {
|
||||
/* harmony export */ ZY: () => (/* binding */ convertVersionToSemver),
|
||||
/* harmony export */ aT: () => (/* binding */ isGhes),
|
||||
/* harmony export */ ag: () => (/* binding */ getDownloadArchiveExtension),
|
||||
/* harmony export */ lN: () => (/* binding */ isJdkCacheEnabled),
|
||||
/* harmony export */ n2: () => (/* binding */ renameWinArchive),
|
||||
/* harmony export */ rC: () => (/* binding */ getNextPageUrlFromLinkHeader),
|
||||
/* harmony export */ ri: () => (/* binding */ getLatestMajorVersion),
|
||||
@@ -31286,6 +31289,11 @@ function getBooleanInput(inputName, defaultValue = false) {
|
||||
}
|
||||
throw new Error(`Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.`);
|
||||
}
|
||||
function isJdkCacheEnabled(cache) {
|
||||
return _actions_core__WEBPACK_IMPORTED_MODULE_4__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_6__/* .INPUT_CACHE_JDK */ .GL).trim()
|
||||
? getBooleanInput(_constants_js__WEBPACK_IMPORTED_MODULE_6__/* .INPUT_CACHE_JDK */ .GL)
|
||||
: Boolean(cache.trim());
|
||||
}
|
||||
function getVersionFromToolcachePath(toolPath) {
|
||||
if (toolPath) {
|
||||
return path.basename(path.dirname(toolPath));
|
||||
@@ -31890,6 +31898,7 @@ __nccwpck_require__.d(__webpack_exports__, {
|
||||
dN: () => (/* binding */ exportVariable),
|
||||
V4: () => (/* binding */ getInput),
|
||||
q3: () => (/* binding */ getMultilineInput),
|
||||
Gu: () => (/* binding */ getState),
|
||||
pq: () => (/* binding */ info),
|
||||
_o: () => (/* binding */ isDebug),
|
||||
LZ: () => (/* binding */ saveState),
|
||||
@@ -31900,7 +31909,7 @@ __nccwpck_require__.d(__webpack_exports__, {
|
||||
$e: () => (/* binding */ warning)
|
||||
});
|
||||
|
||||
// UNUSED EXPORTS: ExitCode, getBooleanInput, getIDToken, getState, group, markdownSummary, notice, platform, setCommandEcho, summary, toPlatformPath, toPosixPath, toWin32Path
|
||||
// UNUSED EXPORTS: ExitCode, getBooleanInput, getIDToken, group, markdownSummary, notice, platform, setCommandEcho, summary, toPlatformPath, toPosixPath, toWin32Path
|
||||
|
||||
// EXTERNAL MODULE: external "os"
|
||||
var external_os_ = __nccwpck_require__(857);
|
||||
@@ -36119,6 +36128,7 @@ async function run() {
|
||||
const packageType = setup_java_core/* getInput */.V4(constants/* INPUT_JAVA_PACKAGE */.p1);
|
||||
const jdkFile = getJdkFileInput();
|
||||
const cache = setup_java_core/* getInput */.V4(constants/* INPUT_CACHE */.gk);
|
||||
const cacheJdk = (0,util/* isJdkCacheEnabled */.lN)(cache);
|
||||
const cacheDependencyPath = setup_java_core/* getInput */.V4(constants/* INPUT_CACHE_DEPENDENCY_PATH */.At);
|
||||
const cachePath = setup_java_core/* getMultilineInput */.q3(constants/* INPUT_CACHE_PATH */.uW);
|
||||
const checkLatest = (0,util/* getBooleanInput */.Vt)(constants/* INPUT_CHECK_LATEST */.YM, false);
|
||||
@@ -36157,6 +36167,7 @@ async function run() {
|
||||
packageType,
|
||||
checkLatest,
|
||||
forceDownload,
|
||||
cacheJdk,
|
||||
setDefault,
|
||||
verifySignature,
|
||||
verifySignaturePublicKey,
|
||||
@@ -36179,6 +36190,7 @@ async function run() {
|
||||
packageType,
|
||||
checkLatest,
|
||||
forceDownload,
|
||||
cacheJdk,
|
||||
setDefault,
|
||||
verifySignature,
|
||||
verifySignaturePublicKey,
|
||||
@@ -36231,12 +36243,13 @@ function getJdkFileInput() {
|
||||
return jdkFile || deprecatedJdkFile;
|
||||
}
|
||||
async function installVersion(version, options, toolchainId = 0) {
|
||||
const { distributionName, jdkFile, architecture, packageType, checkLatest, forceDownload, setDefault, verifySignature, verifySignaturePublicKey, toolchainIds } = options;
|
||||
const { distributionName, jdkFile, architecture, packageType, checkLatest, forceDownload, cacheJdk, setDefault, verifySignature, verifySignaturePublicKey, toolchainIds } = options;
|
||||
const installerOptions = {
|
||||
architecture,
|
||||
packageType,
|
||||
checkLatest,
|
||||
forceDownload,
|
||||
cacheJdk,
|
||||
setDefault,
|
||||
verifySignature,
|
||||
verifySignaturePublicKey,
|
||||
|
||||
Reference in New Issue
Block a user