Skip to content

Commit 8b8aeae

Browse files
committed
add more control over caching and forward outputs
1 parent aa57fde commit 8b8aeae

2 files changed

Lines changed: 63 additions & 3 deletions

File tree

setup-and-install/action.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,48 @@ inputs:
1111
distribution:
1212
default: 'corretto'
1313
description: 'Java Distribution'
14+
cache:
15+
default: 'true'
16+
description: 'Enable Maven dependency caching'
17+
cache-name:
18+
default: 'aboutbits-setup-java'
19+
description: 'Cache name. Caches with the same name will share their contents.'
20+
21+
outputs:
22+
distribution:
23+
description: 'Distribution of Java that has been installed'
24+
value: ${{ steps.setup-java.outputs.distribution }}
25+
version:
26+
description: 'Actual version of the java environment that has been installed'
27+
value: ${{ steps.setup-java.outputs.version }}
28+
path:
29+
description: 'Path to where the java environment has been installed (same as $JAVA_HOME)'
30+
value: ${{ steps.setup-java.outputs.path }}
31+
cache-hit:
32+
description: 'A boolean value to indicate an exact match was found for the primary key'
33+
value: ${{ steps.cache.outputs.cache-hit }}
1434

1535
runs:
1636
using: "composite"
1737
steps:
1838
- name: Set up JDK
1939
uses: actions/setup-java@v4
40+
id: setup-java
2041
with:
2142
java-version: ${{ inputs.java-version }}
2243
distribution: ${{ inputs.distribution }}
23-
cache: 'maven'
44+
45+
- name: Cache local Maven repository
46+
uses: actions/cache@v2
47+
id: cache
48+
if: ${{ inputs.cache == 'true' }}
49+
with:
50+
path: ~/.m2/repository
51+
key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
52+
restore-keys: |
53+
${{ inputs.cache-name }}-${{ runner.os }}-maven-
2454
2555
- name: Update maven dependencies
2656
working-directory: ${{ inputs.working-directory }}
27-
run: ./mvnw --batch-mode --fail-fast dependency:resolve
57+
run: ./mvnw --batch-mode --fail-fast dependency:resolve dependency:resolve-plugins
2858
shell: bash

setup/action.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,43 @@ inputs:
1111
distribution:
1212
default: 'corretto'
1313
description: 'Java Distribution'
14+
cache:
15+
default: 'true'
16+
description: 'Enable Maven dependency caching'
17+
cache-name:
18+
default: 'aboutbits-setup-java'
19+
description: 'Cache name. Caches with the same name will share their contents.'
20+
21+
outputs:
22+
distribution:
23+
description: 'Distribution of Java that has been installed'
24+
value: ${{ steps.setup-java.outputs.distribution }}
25+
version:
26+
description: 'Actual version of the java environment that has been installed'
27+
value: ${{ steps.setup-java.outputs.version }}
28+
path:
29+
description: 'Path to where the java environment has been installed (same as $JAVA_HOME)'
30+
value: ${{ steps.setup-java.outputs.path }}
31+
cache-hit:
32+
description: 'A boolean value to indicate an exact match was found for the primary key'
33+
value: ${{ steps.cache.outputs.cache-hit }}
1434

1535
runs:
1636
using: "composite"
1737
steps:
1838
- name: Set up JDK
1939
uses: actions/setup-java@v4
40+
id: setup-java
2041
with:
2142
java-version: ${{ inputs.java-version }}
2243
distribution: ${{ inputs.distribution }}
23-
cache: 'maven'
44+
45+
- name: Cache local Maven repository
46+
uses: actions/cache@v2
47+
id: cache
48+
if: ${{ inputs.cache == 'true' }}
49+
with:
50+
path: ~/.m2/repository
51+
key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
52+
restore-keys: |
53+
${{ inputs.cache-name }}-${{ runner.os }}-maven-

0 commit comments

Comments
 (0)