Description
Description:
When using actions/setup-java@v4 with Maven cache (cache: maven), CI builds often download Maven plugin dependencies (e.g., plexus-*, aircompressor, xz) even when the POM and project dependencies have not changed. The cache log shows: “Cache hit occurred on the primary key …, not saving cache”, so these plugin JARs are not persisted and are downloaded again in subsequent builds.
It would be helpful to have a way to configure setup-java so that plugin dependencies can also be cached, or otherwise reduce repeated downloads in CI builds.
Justification:
For multi-module Maven projects with many plugins, repeated downloads of plugin dependencies increase CI build time and network usage. Providing a way to cache plugin dependencies would make CI runs faster and more efficient, especially on runners that start from a clean environment each time.
Are you willing to submit a PR?
No.
Activity
v-chiranjib-swain commentedon Mar 19, 2026
Hello @dbi1463 , Thank you for raising this and we will get back to you once we have some feedback on this .
feat: add .mvn/extensions.xml to Maven cache key pattern
feat: add .mvn/extensions.xml to Maven cache key pattern (actions#1041)
brunoborges commentedon Jul 8, 2026
@gdams reopening as this issue is different than PR #1041
docs: document seeding the Maven cache for plugin dependencies (#1094)
brunoborges commentedon Jul 9, 2026
Documented in #1094.
Root cause: with
cache: maventhe action saves whatever a run downloads into~/.m2and does not re-save on a cache hit. Maven resolves plugin dependencies lazily (only for the goals that run), so a cache first created by a thin goal likemvn compilenever captures plugins bound to later phases (e.g.maven-shade-pluginand its depsplexus-archiver,commons-compress,aircompressor,xz), which then get re-downloaded on every subsequenttest/verify/packagerun.Workaround now documented (README + advanced-usage): add a seed step that resolves project and plugin dependencies on the cache-creating run, so all jobs share a complete cache:
The docs include a goal-comparison table, single-job and separate-seed-job (matrix) examples, and caveats (seed only helps on the cache-creating run; static resolution is not exhaustive; seed at the reactor root for multi-module).
feat: add .mvn/extensions.xml to Maven cache key pattern (actions#1041)