mirror of
https://github.com/s4u/setup-maven-action.git
synced 2026-02-12 00:05:30 +08:00
Use actions/cache
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -28,8 +28,8 @@ jobs:
|
|||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
java-cache: maven
|
|
||||||
maven-version: ${{ matrix.maven }}
|
maven-version: ${{ matrix.maven }}
|
||||||
|
cache-prefix: 'test-prefix-'
|
||||||
|
|
||||||
- run: mvn -V validate -Drequire.java=${{ matrix.java }} -Drequire.maven=${{ matrix.maven }}
|
- run: mvn -V validate -Drequire.java=${{ matrix.java }} -Drequire.maven=${{ matrix.maven }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
25
README.md
25
README.md
@ -4,6 +4,7 @@
|
|||||||
This is composite action which help to prepare GitHub Actions environment for Maven build by calling:
|
This is composite action which help to prepare GitHub Actions environment for Maven build by calling:
|
||||||
|
|
||||||
- [actions/setup-java](https://github.com/marketplace/actions/setup-java-jdk)
|
- [actions/setup-java](https://github.com/marketplace/actions/setup-java-jdk)
|
||||||
|
- [actions/cache](https://github.com/marketplace/actions/cache)
|
||||||
- [stCarolas/setup-maven](https://github.com/marketplace/actions/setup-maven)
|
- [stCarolas/setup-maven](https://github.com/marketplace/actions/setup-maven)
|
||||||
- [s4u/maven-settings-action](https://github.com/marketplace/actions/maven-settings-action)
|
- [s4u/maven-settings-action](https://github.com/marketplace/actions/maven-settings-action)
|
||||||
|
|
||||||
@ -27,7 +28,29 @@ or use automatic tools like [Dependabot](https://docs.github.com/en/code-securit
|
|||||||
| ----------------- |------------- |-------- |
|
| ----------------- |------------- |-------- |
|
||||||
| java-version | java-version | |
|
| java-version | java-version | |
|
||||||
| java-distribution | distribution | temurin |
|
| java-distribution | distribution | temurin |
|
||||||
| java-cache | cache | |
|
|
||||||
|
## cache
|
||||||
|
|
||||||
|
A cache action is configured as:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ inputs.cache-path }}
|
||||||
|
${{ inputs.cache-path-add }}
|
||||||
|
key: ${{ inputs.cache-prefix }}${{ runner.os }}-jdk${{ inputs.java-version }}-${{ inputs.java-distribution }}-maven${{ inputs.maven-version }}-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: ${{ inputs.cache-prefix }}${{ runner.os }}-jdk${{ inputs.java-version }}-${{ inputs.java-distribution }}-maven${{ inputs.maven-version }}-
|
||||||
|
```
|
||||||
|
|
||||||
|
So we can use for action:
|
||||||
|
|
||||||
|
| params | description |
|
||||||
|
| ----------------- |--------------------------------------------------------- |
|
||||||
|
| cache-path | default cache path for Maven with value ~/.m2/repository |
|
||||||
|
| cache-path-add | additional value for cache path |
|
||||||
|
| cache-prefix | prefix value for `key` and `restore-keys` cache params |
|
||||||
|
|
||||||
|
|
||||||
## setup-maven
|
## setup-maven
|
||||||
|
|
||||||
|
|||||||
31
action.yml
31
action.yml
@ -18,14 +18,24 @@ inputs:
|
|||||||
default: 'temurin'
|
default: 'temurin'
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
java-cache:
|
# cache
|
||||||
description: 'Name of the build platform to cache dependencies. It should be "maven" or empty.'
|
cache-prefix:
|
||||||
required: true
|
description: 'Cache key prefix'
|
||||||
|
required: false
|
||||||
|
|
||||||
|
cache-path:
|
||||||
|
description: 'Cache path'
|
||||||
|
default: '~/.m2/repository'
|
||||||
|
required: false
|
||||||
|
|
||||||
|
cache-path-add:
|
||||||
|
description: 'Additional item for cache path'
|
||||||
|
required: false
|
||||||
|
|
||||||
# maven version
|
# maven version
|
||||||
maven-version:
|
maven-version:
|
||||||
description: 'The Maven version to set up'
|
description: 'The Maven version to set up'
|
||||||
default: 3.8.1
|
default: '3.8.1'
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
# maven settings.xml
|
# maven settings.xml
|
||||||
@ -57,7 +67,18 @@ runs:
|
|||||||
overwrite-settings: false
|
overwrite-settings: false
|
||||||
java-version: '${{ inputs.java-version }}'
|
java-version: '${{ inputs.java-version }}'
|
||||||
distribution: '${{ inputs.java-distribution }}'
|
distribution: '${{ inputs.java-distribution }}'
|
||||||
cache: '${{ inputs.java-cache }}'
|
- run: echo "::endgroup::"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- run: echo "::group::Setup Cache"
|
||||||
|
shell: bash
|
||||||
|
- uses: actions/cache@v2.1.6
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ inputs.cache-path }}
|
||||||
|
${{ inputs.cache-path-add }}
|
||||||
|
key: ${{ inputs.cache-prefix }}${{ runner.os }}-jdk${{ inputs.java-version }}-${{ inputs.java-distribution }}-maven${{ inputs.maven-version }}-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: ${{ inputs.cache-prefix }}${{ runner.os }}-jdk${{ inputs.java-version }}-${{ inputs.java-distribution }}-maven${{ inputs.maven-version }}-
|
||||||
- run: echo "::endgroup::"
|
- run: echo "::endgroup::"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user