5
0
mirror of https://gitea.com/actions/setup-java.git synced 2026-08-05 02:31:18 +00:00

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>
This commit is contained in:
Bruno Borges
2026-08-04 19:02:19 -04:00
parent 60b1ab8234
commit ee3e6d82d3
21 changed files with 1695 additions and 804 deletions
+14 -5
View File
@@ -24,10 +24,11 @@ async function removePrivateKeyFromKeychain() {
* Check given input and run a save process for the specified package manager
* @returns Promise that will be resolved when the save process finishes
*/
async function saveCache() {
async function saveCaches() {
const jobStatus = isJobStatusSuccess();
const cache = core.getInput(constants.INPUT_CACHE);
if (!jobStatus || !cache) {
const cacheJdk = getBooleanInput(constants.INPUT_CACHE_JDK, true);
if (!jobStatus || (!cache && !cacheJdk)) {
return;
}
@@ -36,8 +37,16 @@ async function saveCache() {
return;
}
const {save} = await import('./cache.js');
await save(cache);
const saves: Promise<void>[] = [];
if (cache) {
const {save} = await import('./cache.js');
saves.push(save(cache));
}
if (cacheJdk) {
const {saveJdkCaches} = await import('./jdk-cache.js');
saves.push(saveJdkCaches());
}
await Promise.all(saves);
}
/**
@@ -59,7 +68,7 @@ async function ignoreError(promise: Promise<void>) {
export async function run() {
await removePrivateKeyFromKeychain();
await ignoreError(saveCache());
await ignoreError(saveCaches());
}
if (process.argv[1] === fileURLToPath(import.meta.url)) {