镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Maven caching fails completely when wrapper files exist but wrapper is not used #1150

Description

@Marcono1234

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.properties file 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:

  1. 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>
  2. Create a dummy .mvn/wrapper/maven-wrapper.properties (content does not matter)
  3. 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
  4. 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

  1. brunoborges commented on Jul 28, 2026

    @brunoborges
    Contributor

    @Marcono1234 this seems like just a warning. Or is it blocking something?

  2. self-assigned this
    on Jul 28, 2026
  3. Marcono1234 commented on Jul 28, 2026

    @Marcono1234
    ContributorAuthor

    this seems like just a warning. Or is it blocking something?

    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/repository cache which I assume would have been saved after the wrapper.

  4. Marcono1234 commented on Jul 28, 2026

    @Marcono1234
    ContributorAuthor

    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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmaintenanceInternal refactors/chore work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions