Unverified Commit 81c13a41 authored by Bruno Borges's avatar Bruno Borges Committed by GitHub
Browse files

Cache Maven and Gradle wrapper distributions separately from the dependency cache (#1097)

* Cache Maven wrapper distribution separately from the local repository

The Maven wrapper distribution (~/.m2/wrapper/dists) was cached in the same
entry as the local Maven repository (~/.m2/repository), keyed on a hash of
**/pom.xml (plus wrapper properties and extensions). Because pom.xml changes
frequently and no restoreKeys are used (by design, #269), almost every change
produces a full cache miss and the wrapper distribution is re-downloaded via
mvnw — which intermittently fails due to upstream rate limiting.

The wrapper distribution only depends on maven-wrapper.properties, which
changes very rarely. Give it its own cache entry keyed solely on
**/.mvn/wrapper/maven-wrapper.properties so it survives the frequent pom.xml
changes that rotate the main dependency cache key.

- Add a generic additionalCaches concept to PackageManager, restored and saved
  independently with name-scoped state keys.
- Move ~/.m2/wrapper/dists out of the main maven path into a maven-wrapper
  additional cache; skip silently when the project does not use mvnw.
- Keep cache-hit / cache-primary-key outputs driven by the main cache.
- Update tests, docs, and rebuild dist bundles.

Fixes #1095

Co-authored-by: default avatarCopilot App <[email protected]>

* Cache Gradle wrapper distribution separately from the dependency cache (#1098)

The Gradle wrapper distribution (~/.gradle/wrapper) only depends on
gradle-wrapper.properties, which changes rarely, but it was previously
cached in the same entry as ~/.gradle/caches, keyed on volatile
**/*.gradle* files with no restoreKeys (issue #269). Every dependency
change therefore re-downloaded the wrapper.

Move ~/.gradle/wrapper into a dedicated `gradle-wrapper` additional
cache keyed only on **/gradle-wrapper.properties, reusing the
additionalCaches infrastructure introduced for the Maven wrapper fix.

Co-authored-by: default avatarCopilot App <[email protected]>

* Potential fix for pull request finding

Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>

* Potential fix for pull request finding

Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>

* Potential fix for pull request finding

Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>

* Fix broken try/catch in saveAdditionalCache and rebuild dist

The autofix commits dropped the `} catch (error) {` line in
saveAdditionalCache, leaving a `try` block without a catch and a dangling
`error` reference, which broke compilation and Prettier. Restore the catch
clause, reformat, and regenerate the dist bundles.

Co-authored-by: default avatarCopilot App <[email protected]>

* Address cache.ts review feedback

- saveAdditionalCache: handle @actions/cache ValidationError (thrown when the
  cache paths do not resolve, e.g. the wrapper distribution was never
  downloaded) by skipping instead of failing the post step. Add a test.
- Point the Gradle wrapper cache comment at issue #269 (Gradle wrapper cache
  churn) instead of the Maven-specific #1095.

Co-authored-by: default avatarCopilot App <[email protected]>

* Document Gradle Wrapper distribution caching in README

Add a parallel "Gradle Wrapper" note alongside the Maven Wrapper note, so the
new behavior for cache: 'gradle' (caching ~/.gradle/wrapper in a separate entry
keyed on **/gradle-wrapper.properties) is documented.

Co-authored-by: default avatarCopilot App <[email protected]>

---------

Co-authored-by: default avatarCopilot App <[email protected]>
Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>
parent 3c85b143
Loading
Loading
Loading
Loading
+3 −1
Changes for README.md: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ The workflow output `cache-primary-key` exposes the primary cache key computed b

The cache input is optional, and caching is turned off by default.

**Maven Wrapper:** when `cache: 'maven'` is enabled, the action also caches and restores the Maven Wrapper distribution downloaded to `~/.m2/wrapper/dists` (in addition to the local repository), so wrapper-based (`./mvnw`) builds don't re-download the wrapper on every run. This is keyed on `**/.mvn/wrapper/maven-wrapper.properties` as shown above.
**Maven Wrapper:** when `cache: 'maven'` is enabled, the action also caches and restores the Maven Wrapper distribution downloaded to `~/.m2/wrapper/dists` (in addition to the local repository), so wrapper-based (`./mvnw`) builds don't re-download the Maven distribution. The wrapper distribution is stored in a **separate** cache entry keyed only on `**/.mvn/wrapper/maven-wrapper.properties`, so it stays cached across the frequent `pom.xml` changes that rotate the main dependency cache key.

#### Caching gradle dependencies
```yaml
@@ -181,6 +181,8 @@ steps:
```
Using the `cache: gradle` provides a simple and effective way to cache Gradle dependencies with minimal configuration.

**Gradle Wrapper:** when `cache: 'gradle'` is enabled, the action also caches and restores the Gradle Wrapper distribution downloaded to `~/.gradle/wrapper` (in addition to the Gradle caches), so wrapper-based (`./gradlew`) builds don't re-download the Gradle distribution. The wrapper distribution is stored in a **separate** cache entry keyed only on `**/gradle-wrapper.properties`, so it stays cached across the frequent `*.gradle*` changes that rotate the main dependency cache key.

For projects that require more advanced `Gradle` caching features, such as caching build outputs, support for Gradle configuration cache, encrypted cache storage, fine-grained cache control (including options to enable or disable the cache, set it to read-only or write-only, perform automated cleanup, and define custom cache rules), or optimized performance for complex CI workflows, consider using [`gradle/actions/setup-gradle`](https://github.com/gradle/actions/tree/main/setup-gradle).  

For setup details and a comprehensive overview of all available features, visit the [setup-gradle documentation](https://github.com/gradle/actions/blob/main/docs/setup-gradle.md).
+196 −12
Changes for __tests__/cache.test.ts: 196 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -166,10 +166,7 @@ describe('dependency cache', () => {

        await restore('maven', '');
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [
            join(os.homedir(), '.m2', 'repository'),
            join(os.homedir(), '.m2', 'wrapper', 'dists')
          ],
          [join(os.homedir(), '.m2', 'repository')],
          expect.any(String)
        );
        expect(spyGlobHashFiles).toHaveBeenCalledWith(
@@ -196,10 +193,7 @@ describe('dependency cache', () => {

        await restore('maven', '');
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [
            join(os.homedir(), '.m2', 'repository'),
            join(os.homedir(), '.m2', 'wrapper', 'dists')
          ],
          [join(os.homedir(), '.m2', 'repository')],
          expect.any(String)
        );
        expect(spyGlobHashFiles).toHaveBeenCalledWith(
@@ -214,10 +208,7 @@ describe('dependency cache', () => {

        await restore('maven', '');
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [
            join(os.homedir(), '.m2', 'repository'),
            join(os.homedir(), '.m2', 'wrapper', 'dists')
          ],
          [join(os.homedir(), '.m2', 'repository')],
          expect.any(String)
        );
        expect(spyGlobHashFiles).toHaveBeenCalledWith(
@@ -226,6 +217,47 @@ describe('dependency cache', () => {
        expect(spyWarning).not.toHaveBeenCalled();
        expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
      });
      it('restores the maven wrapper distribution cache independently of the main cache', async () => {
        createDirectory(join(workspace, '.mvn'));
        createDirectory(join(workspace, '.mvn', 'wrapper'));
        createFile(
          join(workspace, '.mvn', 'wrapper', 'maven-wrapper.properties')
        );

        await restore('maven', '');
        // Main dependency cache no longer carries the wrapper dists path.
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [join(os.homedir(), '.m2', 'repository')],
          expect.any(String)
        );
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [join(os.homedir(), '.m2', 'wrapper', 'dists')],
          expect.stringContaining('maven-wrapper')
        );
        expect(spyGlobHashFiles).toHaveBeenCalledWith(
          '**/.mvn/wrapper/maven-wrapper.properties'
        );
      });
      it('skips the maven wrapper cache when no wrapper properties exist', async () => {
        createFile(join(workspace, 'pom.xml'));
        spyGlobHashFiles.mockImplementation((pattern: string) =>
          Promise.resolve(
            pattern === '**/.mvn/wrapper/maven-wrapper.properties'
              ? ''
              : 'hash-stub'
          )
        );

        await restore('maven', '');
        // Only the main dependency cache is restored; the wrapper cache path is
        // never touched because the project does not use mvnw.
        expect(spyCacheRestore).toHaveBeenCalledTimes(1);
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [join(os.homedir(), '.m2', 'repository')],
          expect.any(String)
        );
        expect(spyWarning).not.toHaveBeenCalled();
      });
    });
    describe('for gradle', () => {
      it('throws error if no build.gradle found', async () => {
@@ -282,6 +314,43 @@ describe('dependency cache', () => {
        expect(spyWarning).not.toHaveBeenCalled();
        expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
      });
      it('restores the gradle wrapper distribution cache independently of the main cache', async () => {
        createFile(join(workspace, 'build.gradle'));

        await restore('gradle', '');
        // Main dependency cache no longer carries the wrapper path.
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [join(os.homedir(), '.gradle', 'caches')],
          expect.any(String)
        );
        // Wrapper distribution is restored on its own, keyed only on the
        // wrapper properties file.
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [join(os.homedir(), '.gradle', 'wrapper')],
          expect.stringContaining('setup-java-')
        );
        expect(spyGlobHashFiles).toHaveBeenCalledWith(
          '**/gradle-wrapper.properties'
        );
      });
      it('skips the gradle wrapper cache when no wrapper properties exist', async () => {
        createFile(join(workspace, 'build.gradle'));
        spyGlobHashFiles.mockImplementation((pattern: string) =>
          Promise.resolve(
            pattern === '**/gradle-wrapper.properties' ? '' : 'hash-stub'
          )
        );

        await restore('gradle', '');
        // Only the main dependency cache is restored; the wrapper cache path is
        // never touched because the project does not use the gradle wrapper.
        expect(spyCacheRestore).toHaveBeenCalledTimes(1);
        expect(spyCacheRestore).toHaveBeenCalledWith(
          [join(os.homedir(), '.gradle', 'caches')],
          expect.any(String)
        );
        expect(spyWarning).not.toHaveBeenCalled();
      });
    });
    describe('for sbt', () => {
      it('throws error if no build.sbt found', async () => {
@@ -457,6 +526,77 @@ describe('dependency cache', () => {
          expect.stringMatching(/^Cache saved with the key:.*/)
        );
      });
      it('saves the maven wrapper distribution cache under its own key', async () => {
        createFile(join(workspace, 'pom.xml'));
        (core.getState as jest.Mock<any>).mockImplementation((name: any) => {
          switch (name) {
            case 'cache-primary-key':
              return 'setup-java-cache-primary-key';
            case 'cache-matched-key':
              return 'setup-java-cache-matched-key';
            case 'cache-primary-key-maven-wrapper':
              return 'setup-java-maven-wrapper-key';
            default:
              return '';
          }
        });

        await save('maven');
        expect(spyCacheSave).toHaveBeenCalledWith(
          [join(os.homedir(), '.m2', 'wrapper', 'dists')],
          'setup-java-maven-wrapper-key'
        );
        expect(spyWarning).not.toHaveBeenCalled();
      });
      it('does not save the maven wrapper cache on an exact wrapper hit', async () => {
        createFile(join(workspace, 'pom.xml'));
        (core.getState as jest.Mock<any>).mockImplementation((name: any) => {
          switch (name) {
            case 'cache-primary-key':
              return 'setup-java-cache-primary-key';
            case 'cache-matched-key':
              return 'setup-java-cache-matched-key';
            case 'cache-primary-key-maven-wrapper':
            case 'cache-matched-key-maven-wrapper':
              return 'setup-java-maven-wrapper-key';
            default:
              return '';
          }
        });

        await save('maven');
        expect(spyCacheSave).not.toHaveBeenCalledWith(
          [join(os.homedir(), '.m2', 'wrapper', 'dists')],
          expect.any(String)
        );
      });
      it('does not fail the post step when the wrapper distribution path is missing', async () => {
        createFile(join(workspace, 'pom.xml'));
        (core.getState as jest.Mock<any>).mockImplementation((name: any) => {
          switch (name) {
            case 'cache-primary-key':
              return 'setup-java-cache-primary-key';
            case 'cache-matched-key':
              return 'setup-java-cache-matched-key';
            case 'cache-primary-key-maven-wrapper':
              return 'setup-java-maven-wrapper-key';
            default:
              return '';
          }
        });
        spyCacheSave.mockImplementation((paths: string[]) =>
          paths.includes(join(os.homedir(), '.m2', 'wrapper', 'dists'))
            ? Promise.reject(
                new cache.ValidationError(
                  'Path Validation Error: Path(s) specified in the action for caching do(es) not exist'
                )
              )
            : Promise.resolve(0)
        );

        await expect(save('maven')).resolves.toBeUndefined();
        expect(spyWarning).not.toHaveBeenCalled();
      });
    });
    describe('for gradle', () => {
      it('uploads cache even if no build.gradle found', async () => {
@@ -509,6 +649,50 @@ describe('dependency cache', () => {
          expect.stringMatching(/^Cache saved with the key:.*/)
        );
      });
      it('saves the gradle wrapper distribution cache under its own key', async () => {
        createFile(join(workspace, 'build.gradle'));
        (core.getState as jest.Mock<any>).mockImplementation((name: any) => {
          switch (name) {
            case 'cache-primary-key':
              return 'setup-java-cache-primary-key';
            case 'cache-matched-key':
              return 'setup-java-cache-matched-key';
            case 'cache-primary-key-gradle-wrapper':
              return 'setup-java-gradle-wrapper-key';
            default:
              return '';
          }
        });

        await save('gradle');
        expect(spyCacheSave).toHaveBeenCalledWith(
          [join(os.homedir(), '.gradle', 'wrapper')],
          'setup-java-gradle-wrapper-key'
        );
        expect(spyWarning).not.toHaveBeenCalled();
      });
      it('does not save the gradle wrapper cache on an exact wrapper hit', async () => {
        createFile(join(workspace, 'build.gradle'));
        (core.getState as jest.Mock<any>).mockImplementation((name: any) => {
          switch (name) {
            case 'cache-primary-key':
              return 'setup-java-cache-primary-key';
            case 'cache-matched-key':
              return 'setup-java-cache-matched-key';
            case 'cache-primary-key-gradle-wrapper':
            case 'cache-matched-key-gradle-wrapper':
              return 'setup-java-gradle-wrapper-key';
            default:
              return '';
          }
        });

        await save('gradle');
        expect(spyCacheSave).not.toHaveBeenCalledWith(
          [join(os.homedir(), '.gradle', 'wrapper')],
          expect.any(String)
        );
      });
    });
    describe('for sbt', () => {
      it('uploads cache even if no build.sbt found', async () => {
+120 −9
Changes for dist/cleanup/index.js: 120 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -99666,23 +99666,28 @@ const CACHE_KEY_PREFIX = 'setup-java';
const supportedPackageManager = [
    {
        id: 'maven',
        path: [
            (0,external_path_.join)(external_os_default().homedir(), '.m2', 'repository'),
            (0,external_path_.join)(external_os_default().homedir(), '.m2', 'wrapper', 'dists')
        ],
        path: [(0,external_path_.join)(external_os_default().homedir(), '.m2', 'repository')],
        // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
        pattern: [
            '**/pom.xml',
            '**/.mvn/wrapper/maven-wrapper.properties',
            '**/.mvn/extensions.xml'
        ],
        // The Maven wrapper distribution only depends on the wrapper properties,
        // which change very rarely, so it is cached separately from the local
        // repository. This keeps it available across the frequent pom.xml changes
        // that rotate the main cache key. See issue #1095.
        additionalCaches: [
            {
                name: 'maven-wrapper',
                path: [(0,external_path_.join)(external_os_default().homedir(), '.m2', 'wrapper', 'dists')],
                pattern: ['**/.mvn/wrapper/maven-wrapper.properties']
            }
        ]
    },
    {
        id: 'gradle',
        path: [
            (0,external_path_.join)(external_os_default().homedir(), '.gradle', 'caches'),
            (0,external_path_.join)(external_os_default().homedir(), '.gradle', 'wrapper')
        ],
        path: [(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'caches')],
        // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
        pattern: [
            '**/*.gradle*',
@@ -99691,6 +99696,17 @@ const supportedPackageManager = [
            'buildSrc/**/Dependencies.kt',
            'gradle/*.versions.toml',
            '**/versions.properties'
        ],
        // The Gradle wrapper distribution only depends on the wrapper properties,
        // which change very rarely, so it is cached separately from the Gradle
        // caches. This keeps it available across the frequent *.gradle* changes
        // that rotate the main cache key. See issue #269.
        additionalCaches: [
            {
                name: 'gradle-wrapper',
                path: [(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'wrapper')],
                pattern: ['**/gradle-wrapper.properties']
            }
        ]
    },
    {
@@ -99726,6 +99742,19 @@ function findPackageManager(id) {
    }
    return packageManager;
}
/**
 * State keys used to carry an additional cache's restore-time information over
 * to the post (save) action, scoped by the additional cache name.
 */
function additionalCachePrimaryKeyState(name) {
    return `${STATE_CACHE_PRIMARY_KEY}-${name}`;
}
function additionalCacheMatchedKeyState(name) {
    return `${CACHE_MATCHED_KEY}-${name}`;
}
function buildCacheKey(id, fileHash) {
    return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${id}-${fileHash}`;
}
/**
 * A function that generates a cache key to use.
 * Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
@@ -99739,7 +99768,19 @@ async function computeCacheKey(packageManager, cacheDependencyPath) {
    if (!fileHash) {
        throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
    }
    return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
    return buildCacheKey(packageManager.id, fileHash);
}
/**
 * Computes the cache key for an additional cache. Unlike {@link computeCacheKey}
 * this returns undefined (instead of throwing) when no file matches the pattern,
 * because additional caches are optional features that many projects do not use.
 */
async function computeAdditionalCacheKey(additionalCache) {
    const fileHash = await glob.hashFiles(additionalCache.pattern.join('\n'));
    if (!fileHash) {
        return undefined;
    }
    return buildCacheKey(additionalCache.name, fileHash);
}
/**
 * Restore the dependency cache
@@ -99763,6 +99804,29 @@ async function restore(id, cacheDependencyPath) {
        core.setOutput('cache-hit', false);
        core.info(`${packageManager.id} cache is not found`);
    }
    for (const additionalCache of packageManager.additionalCaches ?? []) {
        await restoreAdditionalCache(additionalCache);
    }
}
/**
 * Restore an additional cache (e.g. a build-tool wrapper distribution) that is
 * keyed independently of the main dependency cache so that it survives changes
 * to volatile dependency files. Skips silently when the project does not use
 * the corresponding feature.
 */
async function restoreAdditionalCache(additionalCache) {
    const primaryKey = await computeAdditionalCacheKey(additionalCache);
    if (!primaryKey) {
        core.debug(`No file matched [${additionalCache.pattern}] for the ${additionalCache.name} cache, skipping.`);
        return;
    }
    core.debug(`${additionalCache.name} primary key is ${primaryKey}`);
    core.saveState(additionalCachePrimaryKeyState(additionalCache.name), primaryKey);
    const matchedKey = await cache.restoreCache(additionalCache.path, primaryKey);
    if (matchedKey) {
        core.saveState(additionalCacheMatchedKeyState(additionalCache.name), matchedKey);
        core.info(`${additionalCache.name} cache restored from key: ${matchedKey}`);
    }
}
/**
 * Save the dependency cache
@@ -99773,6 +99837,9 @@ async function save(id) {
    const matchedKey = getState(CACHE_MATCHED_KEY);
    // Inputs are re-evaluated before the post action, so we want the original key used for restore
    const primaryKey = getState(STATE_CACHE_PRIMARY_KEY);
    for (const additionalCache of packageManager.additionalCaches ?? []) {
        await saveAdditionalCache(packageManager, additionalCache);
    }
    if (!primaryKey) {
        warning('Error retrieving key from state.');
        return;
@@ -99807,6 +99874,50 @@ async function save(id) {
        }
    }
}
/**
 * Save an additional cache under its own key. Skips when no key was recorded at
 * restore time (feature unused) or when the exact key was already restored.
 */
async function saveAdditionalCache(packageManager, additionalCache) {
    const primaryKey = getState(additionalCachePrimaryKeyState(additionalCache.name));
    const matchedKey = getState(additionalCacheMatchedKeyState(additionalCache.name));
    if (!primaryKey) {
        // The feature is not used by this project, nothing to save.
        core_debug(`No primary key for the ${additionalCache.name} cache, not saving cache.`);
        return;
    }
    else if (matchedKey === primaryKey) {
        info(`Cache hit occurred on the ${additionalCache.name} primary key ${primaryKey}, not saving cache.`);
        return;
    }
    try {
        const cacheId = await cache_saveCache(additionalCache.path, primaryKey);
        if (cacheId === -1) {
            core_debug(`${additionalCache.name} cache was not saved for the key: ${primaryKey}`);
            return;
        }
        info(`${additionalCache.name} cache saved with the key: ${primaryKey}`);
    }
    catch (error) {
        const err = error;
        if (err.name === ValidationError.name) {
            // The cache paths did not resolve, e.g. the wrapper distribution was
            // never downloaded because a system build tool was used or the download
            // failed. Optional wrapper caches must not fail the post step, so skip.
            core_debug(`${additionalCache.name} cache paths do not exist, not saving cache: ${err.message}`);
            return;
        }
        if (err.name === ReserveCacheError.name) {
            info(err.message);
        }
        else {
            if (isProbablyGradleDaemonProblem(packageManager, err)) {
                warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.');
            }
            throw error;
        }
    }
}
/**
 * @param packageManager the specified package manager by user
 * @param error the error thrown by the saveCache
+120 −9

File changed.

Preview size limit exceeded, changes collapsed.

+9 −2
Changes for docs/advanced-usage.md: 9 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -304,8 +304,7 @@ To run the JavaFX application in CI:
## Ensuring the Maven cache is complete (plugin dependencies)

When you enable `cache: maven`, the action caches your local Maven repository
(`~/.m2/repository`) and downloaded Maven Wrapper distributions
(`~/.m2/wrapper/dists`). The cache key is a hash of your Maven inputs — every
(`~/.m2/repository`). The cache key is a hash of your Maven inputs — every
`**/pom.xml`, plus `**/.mvn/wrapper/maven-wrapper.properties` and
`**/.mvn/extensions.xml` — so changing any of those files (for example bumping
the wrapper version or editing core extensions) produces a new key and
@@ -313,6 +312,14 @@ invalidates the cache. At the end of the job the action saves whatever was
downloaded during that run. It does **not** re-save the cache when the key
already matches (a cache *hit*).

Downloaded Maven Wrapper distributions (`~/.m2/wrapper/dists`) are cached in a
**separate** cache entry keyed only on `**/.mvn/wrapper/maven-wrapper.properties`.
Because the wrapper distribution changes far less often than your `pom.xml`
files, this keeps it available across the frequent dependency changes that
rotate the main cache key, so wrapper-based (`./mvnw`) builds don't re-download
the Maven distribution on every dependency change. See
[issue #1095](https://github.com/actions/setup-java/issues/1095).

Maven resolves **plugin** dependencies lazily: it only downloads the plugins and
plugin dependencies required by the goals that actually execute. As a result, the
run that first creates the cache determines what is stored. If that run executed a
Loading