Maven cache not working
See original GitHub issueDescription: Maven always download the dependencies even if the cache is created
Task version: v2
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Repro steps:
- name: Setup java 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
check-latest: true
cache: 'maven'
- run: mvn jacoco:report clean package
Expected behavior: After a first execution, the cache should contain all my dependencies and be already on the disk for the next execution of mvn command.
Actual behavior: Dependencies are still downloaded.
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/cba13e92-7e18-4a5b-831a-2516c488fb74/cache.tzst -P -C /home/runner/work/dst--backoffice-consumer/dst--backoffice-consumer
Cache restored successfully
Cache restored from key: setup-java-Linux-maven-5f5e8c790dbd1362edf8553421a3c7c1d75d42ca90ded98d3f4e4cd4450a9dea
I modified my pom.xml
to generate a different hash but the cache is still hit. I think there is a configuration issue somewhere but don’t know where.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
maven cache in pipeline seems not working
Solved: I have added below script in pipeline, but it seems not working , every build take more than 30 min for mvn...
Read more >Maven artifact caching is not working with maven profiles #255
Description: The primary cache key is calculated based on a hash of all the pom files in the repository. The problem is that...
Read more >How do you clear Apache Maven's cache? - Stack Overflow
Recently, Apache Maven seems to be having caching issues. Performing clean installs on our projects using Windows Vista or Windows 7 ...
Read more >Clearing the Maven Cache | Baeldung
In this short tutorial, we'll explore ways to clear our local Maven cache.
Read more >How to cache entire local Maven repository?
cache hit (10kB retrieved); successful maven build, downloads plenty of ... If you have other issues related to Azure DevOps, please feel free...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @gdrouet. It looks like this is an expected behaviour. The setup-java action has restore-keys, that is why you get the previous cache back. The action saves new cache if the pom.xml file is updated, but initially it restores the previous one. New builds run on the clean machine, that is why cache does not persist on it. Cache is restored from the faster azure storage during the build to provide dependencies.
Did you install dependencies for new project ? It looks like you didn’t install dependencies, that is why the cache archive is empty.
Hello @gdrouet. Thank you for your response. I don’t think it’s related to initial cache activation. I suppose, this is an issue with initial project configuration. Possibly you had problems with downloading during the first caching, that is why no dependencies did not exist in the cache directory. The action saved an empty directory. The action could resave all dependencies when the project configuration was fixed and saving of cache was triggered by pom.xml hash update.
For now I’m closing the issue.