Skip to content

Commit 4a300cd

Browse files
authored
Merge pull request #6 from aboutbits/add-gradle-support
Add Gradle support
2 parents c19ed14 + 16f2bab commit 4a300cd

5 files changed

Lines changed: 134 additions & 34 deletions

File tree

readme.md

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GitHub Actions Java
22

3-
A collection of GitHub actions for Java projects.
3+
A collection of GitHub actions for Java projects with Maven and Gradle support.
44

55
## Actions
66

@@ -11,64 +11,73 @@ This action will set up the Java SDK.
1111
#### Example:
1212

1313
```yaml
14-
- uses: aboutbits/github-actions-java/setup@v3
14+
# Maven
15+
- uses: aboutbits/github-actions-java/setup-with-maven@v4
16+
17+
# Gradle
18+
- uses: aboutbits/github-actions-java/setup-with-gradle@v4
1519
```
1620
1721
#### Inputs
1822
1923
The following inputs can be used as `step.with` keys:
2024

21-
| Name | Required/Default | Description |
22-
|---------------------|------------------------|------------------------------------------------------------------|
23-
| `working-directory` | `.` | The working directory |
24-
| `java-version` | `21` | Java Version |
25-
| `distribution` | `corretto` | Java Distribution |
26-
| `cache` | `true` | Enable Maven dependency caching. |
27-
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. |
25+
| Name | Required/Default | Description |
26+
|---------------------|------------------------|-------------------------------------------------------------------------------------------------------|
27+
| `working-directory` | `.` | The working directory |
28+
| `java-version` | `21` | Java Version |
29+
| `distribution` | `corretto` | Java Distribution |
30+
| `cache` | `true` | Enable Maven/Gradle dependency caching. |
31+
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. (Not applicable when Gradle is used) |
2832

2933
#### Outputs
3034

3135
The following outputs are forwarded from the underlying `setup-java` and `cache` actions:
3236

33-
| Name | Description |
34-
|----------------|-----------------------------------------------------------------------------|
35-
| `distribution` | Distribution of Java that has been installed. |
36-
| `version` | Actual version of the java environment that has been installed. |
37-
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
38-
| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. |
37+
| Name | Description |
38+
|----------------|----------------------------------------------------------------------------------------------------------------|
39+
| `distribution` | Distribution of Java that has been installed. |
40+
| `version` | Actual version of the java environment that has been installed. |
41+
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
42+
| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. (Not applicable when Gradle is used) |
3943

4044
### Setup Java and Install Dependencies
4145

4246
This action will set up the Java SDK and install all dependencies.
47+
You can choose between the Maven and Gradle build tool.
4348

4449
#### Example:
4550

4651
```yaml
47-
- uses: aboutbits/github-actions-java/setup-and-install@v3
52+
# Maven
53+
- uses: aboutbits/github-actions-java/setup-and-install-with-maven@v4
54+
55+
# Gradle
56+
- uses: aboutbits/github-actions-java/setup-and-install-with-gradle@v4
4857
```
4958

5059
#### Inputs
5160

5261
The following inputs can be used as `step.with` keys:
5362

54-
| Name | Required/Default | Description |
55-
|---------------------|------------------------|------------------------------------------------------------------|
56-
| `working-directory` | `.` | The working directory |
57-
| `java-version` | `21` | Java Version |
58-
| `distribution` | `corretto` | Java Distribution |
59-
| `cache` | `true` | Enable Maven dependency caching. |
60-
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. |
63+
| Name | Required/Default | Description |
64+
|---------------------|------------------------|-------------------------------------------------------------------------------------------------------|
65+
| `working-directory` | `.` | The working directory |
66+
| `java-version` | `21` | Java Version |
67+
| `distribution` | `corretto` | Java Distribution |
68+
| `cache` | `true` | Enable Maven/Gradle dependency caching. |
69+
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. (Not applicable when Gradle is used) |
6170

6271
#### Outputs
6372

6473
The following outputs are forwarded from the underlying `setup-java` and `cache` actions:
6574

66-
| Name | Description |
67-
|----------------|-----------------------------------------------------------------------------|
68-
| `distribution` | Distribution of Java that has been installed. |
69-
| `version` | Actual version of the java environment that has been installed. |
70-
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
71-
| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. |
75+
| Name | Description |
76+
|----------------|----------------------------------------------------------------------------------------------------------------|
77+
| `distribution` | Distribution of Java that has been installed. |
78+
| `version` | Actual version of the java environment that has been installed. |
79+
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
80+
| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. (Not applicable when Gradle is used) |
7281

7382
## Versioning
7483

@@ -78,16 +87,16 @@ versions.
7887
Creating a new minor release:
7988

8089
```bash
81-
git tag v3
90+
git tag v4
8291
git push --tags
8392
```
8493

8594
Replacing an already existing minor release:
8695

8796
```bash
88-
git tag -d v3
89-
git push origin :refs/tags/v3
90-
git tag v3
97+
git tag -d v4
98+
git push origin :refs/tags/v4
99+
git tag v4
91100
git push --tags
92101
```
93102

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Setup Java, Gradle and install dependencies'
2+
description: 'Setup Java SDK, Gradle, fetch and cache packages dependencies'
3+
4+
inputs:
5+
working-directory:
6+
description: 'The working directory'
7+
default: '.'
8+
java-version:
9+
default: '21'
10+
description: 'Java Version'
11+
distribution:
12+
default: 'corretto'
13+
description: 'Java Distribution'
14+
cache:
15+
default: 'true'
16+
description: 'Enable Gradle configuration and dependency caching.'
17+
18+
outputs:
19+
distribution:
20+
description: 'Distribution of Java that has been installed.'
21+
value: ${{ steps.setup-java.outputs.distribution }}
22+
version:
23+
description: 'Actual version of the java environment that has been installed.'
24+
value: ${{ steps.setup-java.outputs.version }}
25+
path:
26+
description: 'Path to where the java environment has been installed (same as $JAVA_HOME).'
27+
value: ${{ steps.setup-java.outputs.path }}
28+
29+
runs:
30+
using: "composite"
31+
steps:
32+
- name: Set up JDK
33+
uses: actions/setup-java@v4
34+
id: setup-java
35+
with:
36+
java-version: ${{ inputs.java-version }}
37+
distribution: ${{ inputs.distribution }}
38+
39+
- name: Setup Gradle
40+
uses: gradle/actions/setup-gradle@v4
41+
with:
42+
cache-disabled: ${{ inputs.cache == 'false' }}
43+
cache-read-only: 'false'
44+
45+
- name: Update dependencies
46+
working-directory: ${{ inputs.working-directory }}
47+
run: ./gradlew build --dry-run
48+
shell: bash
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ runs:
5252
restore-keys: |
5353
${{ inputs.cache-name }}-${{ runner.os }}-maven-
5454
55-
- name: Update maven dependencies
55+
- name: Update Maven dependencies
5656
working-directory: ${{ inputs.working-directory }}
5757
run: ./mvnw --batch-mode --fail-fast dependency:resolve dependency:resolve-plugins
5858
shell: bash

setup-with-gradle/action.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'Setup Java and Gradle'
2+
description: 'Setup Java SDK and Gradle'
3+
4+
inputs:
5+
working-directory:
6+
description: 'The working directory'
7+
default: '.'
8+
java-version:
9+
default: '21'
10+
description: 'Java Version'
11+
distribution:
12+
default: 'corretto'
13+
description: 'Java Distribution'
14+
cache:
15+
default: 'true'
16+
description: 'Enable Gradle dependency caching.'
17+
18+
outputs:
19+
distribution:
20+
description: 'Distribution of Java that has been installed.'
21+
value: ${{ steps.setup-java.outputs.distribution }}
22+
version:
23+
description: 'Actual version of the java environment that has been installed.'
24+
value: ${{ steps.setup-java.outputs.version }}
25+
path:
26+
description: 'Path to where the java environment has been installed (same as $JAVA_HOME).'
27+
value: ${{ steps.setup-java.outputs.path }}
28+
29+
runs:
30+
using: "composite"
31+
steps:
32+
- name: Set up JDK
33+
uses: actions/setup-java@v4
34+
id: setup-java
35+
with:
36+
java-version: ${{ inputs.java-version }}
37+
distribution: ${{ inputs.distribution }}
38+
39+
- name: Setup Gradle
40+
uses: gradle/actions/setup-gradle@v4
41+
with:
42+
cache-disabled: ${{ inputs.cache == 'false' }}
43+
cache-read-only: 'false'

0 commit comments

Comments
 (0)