Maven dependencies are downloaded every time my build workflow is triggered.
Travis CI provides a way to cache maven repository. Does Github actions provider similar functionality that allows to cache maven repository?
At very simple form, the build cache Maven is essentially a hash function which takes Maven project and produces cache key for a project.
the local repository is a directory on the computer where Maven runs. It caches remote downloads and contains temporary build artifacts that you have not yet released.
For completeness, this is an example of how to cache the local Maven repository on subsequent builds:
steps:
# Typical Java workflow steps
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
# Step that does that actual cache save and restore
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Step that runs the tests
- name: Run tests
run: mvn test
See this page for more details.
Apparently as of 10 September 2019 caching of build dependencies is not present in Github Actions. Github staff have acknowledged that this feature is necessary, and have replied that "We're working on caching packages and artifacts between workflow executions, we'll have it by mid-November [2019]."
Source: https://github.community/t5/GitHub-Actions/Caching-files-between-GitHub-Action-executions/m-p/30974/highlight/true#M630
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With