docs
docs copied to clipboard
Update cache action with correct snippet for Java-Maven example.
Code of Conduct
- [X] I have read and agree to the GitHub Docs project's Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
What part(s) of the article would you like to see updated?
Caching dependencies You can cache your dependencies to speed up your workflow runs. After a successful run, your local Maven repository will be stored in a cache. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote Maven repositories. You can cache dependencies simply using the setup-java action or can use cache action for custom and more advanced configuration.
YAML
``steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
Additional information
This can be corrected by updating as below
- name: Cache local Maven repository uses: actions/cache@v3 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven-
Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.
@vinzydev Thanks so much for opening an issue! I'll triage this for the team to take a look :eyes:
Our actions team may be a little slow to respond right now, so we appreciate your patience! :yellow_heart:
Hi @vinzydev, thanks for opening this.
The documented workflow in that section already contains a caching configuration using the cache: maven
option with the actions/setup-java@v3
action (you can see the caching docs for that action here). So, there is no need to manually use the cache
action in this instance.