Skip to content

Commit f0869aa

Browse files
committed
add Gradle support
1 parent c19ed14 commit f0869aa

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

setup-and-install/action.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: 'Setup Java and install dependencies'
2-
description: 'Setup Java SDK, fetch and cache packages dependencies'
1+
name: 'Setup Java, build tool and install dependencies'
2+
description: 'Setup Java SDK, the build tool fetch and cache packages dependencies'
33

44
inputs:
55
working-directory:
@@ -11,12 +11,15 @@ inputs:
1111
distribution:
1212
default: 'corretto'
1313
description: 'Java Distribution'
14+
build-tool:
15+
default: 'Maven'
16+
description: 'The build tool to use. The options `Maven` and `Gradle` are supported'
1417
cache:
1518
default: 'true'
16-
description: 'Enable Maven dependency caching.'
19+
description: 'Enable Maven/Gradle dependency caching.'
1720
cache-name:
1821
default: 'aboutbits-setup-java'
19-
description: 'Cache name. Caches with the same name will share their contents.'
22+
description: 'Maven cache name. Caches with the same name will share their contents. This is not applicable to Gradle as `gradle/actions/setup-gradle` manages caching for us.'
2023

2124
outputs:
2225
distribution:
@@ -45,14 +48,28 @@ runs:
4548
- name: Cache local Maven repository
4649
uses: actions/cache@v4
4750
id: cache
48-
if: ${{ inputs.cache == 'true' }}
51+
if: ${{ inputs.cache == 'true' && inputs.build-tool == 'Maven' }}
4952
with:
5053
path: ~/.m2/repository
5154
key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
5255
restore-keys: |
5356
${{ inputs.cache-name }}-${{ runner.os }}-maven-
5457
55-
- name: Update maven dependencies
58+
- name: Update Maven dependencies
5659
working-directory: ${{ inputs.working-directory }}
60+
if: ${{ inputs.build-tool == 'Maven' }}
5761
run: ./mvnw --batch-mode --fail-fast dependency:resolve dependency:resolve-plugins
5862
shell: bash
63+
64+
- name: Setup Gradle
65+
uses: gradle/actions/setup-gradle@v4
66+
if: ${{ inputs.build-tool == 'Gradle' }}
67+
with:
68+
cache-disabled: ${{ inputs.cache == 'false' }}
69+
cache-read-only: 'false'
70+
71+
- name: Update project configuration and Gradle dependencies
72+
working-directory: ${{ inputs.working-directory }}
73+
if: ${{ inputs.build-tool == 'Gradle' }}
74+
run: ./gradlew build --dry-run
75+
shell: bash

setup/action.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: 'Setup Java'
2-
description: 'Setup Java SDK'
1+
name: 'Setup Java and build tool'
2+
description: 'Setup Java SDK and the build tool'
33

44
inputs:
55
working-directory:
@@ -11,12 +11,15 @@ inputs:
1111
distribution:
1212
default: 'corretto'
1313
description: 'Java Distribution'
14+
build-tool:
15+
default: 'Maven'
16+
description: 'The build tool to use. The options `Maven` and `Gradle` are supported'
1417
cache:
1518
default: 'true'
16-
description: 'Enable Maven dependency caching.'
19+
description: 'Enable Maven/Gradle dependency caching.'
1720
cache-name:
1821
default: 'aboutbits-setup-java'
19-
description: 'Cache name. Caches with the same name will share their contents.'
22+
description: 'Maven cache name. Caches with the same name will share their contents. This is not applicable to Gradle as `gradle/actions/setup-gradle` manages caching for us.'
2023

2124
outputs:
2225
distribution:
@@ -45,9 +48,16 @@ runs:
4548
- name: Cache local Maven repository
4649
uses: actions/cache@v4
4750
id: cache
48-
if: ${{ inputs.cache == 'true' }}
51+
if: ${{ inputs.cache == 'true' && inputs.build-tool == 'Maven' }}
4952
with:
5053
path: ~/.m2/repository
5154
key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
5255
restore-keys: |
5356
${{ inputs.cache-name }}-${{ runner.os }}-maven-
57+
58+
- name: Setup Gradle
59+
uses: gradle/actions/setup-gradle@v4
60+
if: ${{ inputs.build-tool == 'Gradle' }}
61+
with:
62+
cache-disabled: ${{ inputs.cache == 'false' }}
63+
cache-read-only: 'false'

0 commit comments

Comments
 (0)