Skip to content

Commit 8490fce

Browse files
beatngu13google-java-format Team
authored andcommitted
Cache local Maven repository via actions/setup-java
As of August 30, ["`setup-java` supports caching for both Gradle and Maven projects"](https://github.blog/changelog/2021-08-30-github-actions-setup-java-now-supports-dependency-caching/). This helps to reduce the amount of boilerplate code in the workflow file. More details can be found in the [corresponding docs](https://github.com/actions/setup-java#caching-packages-dependencies). (And if you wonder what's the used cache key format: actions/setup-java#215) Fixes #660 COPYBARA_INTEGRATE_REVIEW=#660 from beatngu13:patch-1 47e262b PiperOrigin-RevId: 395674252
1 parent 67f75cb commit 8490fce

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,12 @@ jobs:
5252
access_token: ${{ github.token }}
5353
- name: 'Check out repository'
5454
uses: actions/checkout@v2
55-
- name: 'Cache local Maven repository'
56-
uses: actions/cache@v2
57-
with:
58-
path: ~/.m2/repository
59-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
60-
restore-keys: |
61-
${{ runner.os }}-maven-
6255
- name: 'Set up JDK ${{ matrix.java }}'
6356
uses: actions/setup-java@v2
6457
with:
6558
java-version: ${{ matrix.java }}
6659
distribution: 'zulu'
60+
cache: 'maven'
6761
- name: 'Install'
6862
shell: bash
6963
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
@@ -79,18 +73,12 @@ jobs:
7973
steps:
8074
- name: 'Check out repository'
8175
uses: actions/checkout@v2
82-
- name: 'Cache local Maven repository'
83-
uses: actions/cache@v2
84-
with:
85-
path: ~/.m2/repository
86-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
87-
restore-keys: |
88-
${{ runner.os }}-maven-
8976
- name: 'Set up JDK 15'
9077
uses: actions/setup-java@v2
9178
with:
9279
java-version: 15
9380
distribution: 'zulu'
81+
cache: 'maven'
9482
server-id: sonatype-nexus-snapshots
9583
server-username: CI_DEPLOY_USERNAME
9684
server-password: CI_DEPLOY_PASSWORD

0 commit comments

Comments
 (0)