Repository navigation
Maven caching fails completely when wrapper files exist but wrapper is not used #1150
Description
Description:
#1097 separated Maven wrapper caching, however it seems to have introduced an issue: When a project has Maven wrapper files (more specifically **/.mvn/wrapper/maven-wrapper.properties, which this action is looking for) but intentionally does not use the wrapper for a job but the regular mvn instead, then the complete caching fails with the following warning:
[warning]Error: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.
The problem seems to be that the new code only checks if pattern matches anything (in this case the wrapper file) and then assumes the path (in this case the wrapper distribution) must therefore exist as well and can be cached. But as seen here, this assumption is incorrect. And the cache package then throws an error.
Side notes:
- Might affect the Gradle wrapper in a similar way.
- It seems there is test which is supposed to cover this scenario (?), it even duplicates the cache error message, but it seems it does not actually properly test this scenario? maybe it is missing the
maven-wrapper.propertiesfile to actually trigger caching of the wrapper?
Task version:
5.6.0
Platform:
- Ubuntu
- macOS
- Windows
(probably OS-independent though)
Runner type:
- Hosted
- Self-hosted
Repro steps:
- Create a
pom.xml, for example:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <version>1.0-SNAPSHOT</version> <name>my-app</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.release>17</maven.compiler.release> </properties> </project>
- Create a dummy
.mvn/wrapper/maven-wrapper.properties(content does not matter) - Add a GitHub workflow, e.g.
.github/workflows/maven-caching-test.yml:on: [push] jobs: build: runs-on: windows-latest steps: - uses: actions/checkout@v7 - name: Set up Java uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '17' cache: maven - name: Run Maven # Note: This uses regular `mvn`, not the wrapper run: mvn clean --show-version
- Have a look at the workflow run, especially the "Post Set up Java" step
Expected behavior:
Caching is successful
Actual behavior:
Caching fails with the above mentioned error. Enabling debug logging also shows:
...
[debug]Search path 'C:\Users\runneradmin\.m2\wrapper\dists'
[debug]Cache Paths:
[debug][]
[warning]Error: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.
...
Activity
brunoborges commentedon Jul 28, 2026
@Marcono1234 this seems like just a
warning. Or is it blocking something?Marcono1234 commentedon Jul 28, 2026
It is logged as warning (maybe here?), but is actually an error and seems to abort the complete saving of the cache, including the
.m2/repositorycache which I assume would have been saved after the wrapper.Marcono1234 commentedon Jul 28, 2026
Thanks a lot for the quick fix! At least for my dummy project above that seems to solve the issue, with the log now containing the expected debug output "maven-wrapper cache paths do not exist, not saving cache".