Skip to content

Commit

Permalink
Cache local Maven repository via actions/setup-java
Browse files Browse the repository at this point in the history
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
  • Loading branch information
beatngu13 authored and google-java-format Team committed Sep 9, 2021
1 parent 67f75cb commit 8490fce
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,12 @@ jobs:
access_token: ${{ github.token }}
- name: 'Check out repository'
uses: actions/checkout@v2
- name: 'Cache local Maven repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: 'Set up JDK ${{ matrix.java }}'
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
cache: 'maven'
- name: 'Install'
shell: bash
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
Expand All @@ -79,18 +73,12 @@ jobs:
steps:
- name: 'Check out repository'
uses: actions/checkout@v2
- name: 'Cache local Maven repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: 'Set up JDK 15'
uses: actions/setup-java@v2
with:
java-version: 15
distribution: 'zulu'
cache: 'maven'
server-id: sonatype-nexus-snapshots
server-username: CI_DEPLOY_USERNAME
server-password: CI_DEPLOY_PASSWORD
Expand Down

0 comments on commit 8490fce

Please sign in to comment.