Skip to content

Commit b551f98

Browse files
Update setup-java docs to use v2 version (#18036)
1 parent 1dc3cec commit b551f98

6 files changed

Lines changed: 72 additions & 45 deletions

content/actions/guides/building-and-testing-java-with-ant.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ jobs:
5858
5959
steps:
6060
- uses: actions/checkout@v2
61-
- name: Set up JDK 1.8
62-
uses: actions/setup-java@v1
61+
- name: Set up JDK 11
62+
uses: actions/setup-java@v2
6363
with:
64-
java-version: 1.8
64+
java-version: '11'
65+
distribution: 'adopt'
6566
- name: Build with Ant
6667
run: ant -noinput -buildfile build.xml
6768
```
@@ -70,7 +71,7 @@ jobs:
7071
This workflow performs the following steps:
7172

7273
1. The `checkout` step downloads a copy of your repository on the runner.
73-
2. The `setup-java` step configures the Java 1.8 JDK.
74+
2. The `setup-java` step configures the Java 11 JDK by Adoptium.
7475
3. The "Build with Ant" step runs the default target in your `build.xml` in non-interactive mode.
7576

7677
The default workflow templates are excellent starting points when creating your build and test workflow, and you can customize the template to suit your project’s needs.
@@ -91,9 +92,10 @@ If you use different commands to build your project, or you want to run a differ
9192
```yaml{:copy}
9293
steps:
9394
- uses: actions/checkout@v2
94-
- uses: actions/setup-java@v1
95+
- uses: actions/setup-java@v2
9596
with:
96-
java-version: 1.8
97+
java-version: '11'
98+
distribution: 'adopt'
9799
- name: Run the Ant jar target
98100
run: ant -noinput -buildfile build-ci.xml jar
99101
```
@@ -109,7 +111,11 @@ Ant will usually create output files like JARs, EARs, or WARs in the `build/jar`
109111
```yaml{:copy}
110112
steps:
111113
- uses: actions/checkout@v2
112-
- uses: actions/setup-java@v1
114+
- uses: actions/setup-java@v2
115+
with:
116+
java-version: '11'
117+
distribution: 'adopt'
118+
113119
- run: ant -noinput -buildfile build.xml
114120
- uses: actions/upload-artifact@v2
115121
with:

content/actions/guides/building-and-testing-java-with-gradle.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ jobs:
5858
5959
steps:
6060
- uses: actions/checkout@v2
61-
- name: Set up JDK 1.8
62-
uses: actions/setup-java@v1
61+
- name: Set up JDK 11
62+
uses: actions/setup-java@v2
6363
with:
64-
java-version: 1.8
64+
java-version: '11'
65+
distribution: 'adopt'
6566
- name: Build with Gradle
6667
run: ./gradlew build
6768
```
@@ -70,7 +71,7 @@ jobs:
7071
This workflow performs the following steps:
7172

7273
1. The `checkout` step downloads a copy of your repository on the runner.
73-
2. The `setup-java` step configures the Java 1.8 JDK.
74+
2. The `setup-java` step configures the Java 11 JDK by Adoptium.
7475
3. The "Build with Gradle" step runs the `gradlew` wrapper script to ensure that your code builds, tests pass, and a package can be created.
7576

7677
The default workflow templates are excellent starting points when creating your build and test workflow, and you can customize the template to suit your project’s needs.
@@ -91,9 +92,10 @@ If you use different commands to build your project, or you want to use a differ
9192
```yaml{:copy}
9293
steps:
9394
- uses: actions/checkout@v2
94-
- uses: actions/setup-java@v1
95+
- uses: actions/setup-java@v2
9596
with:
96-
java-version: 1.8
97+
java-version: '11'
98+
distribution: 'adopt'
9799
- name: Run the Gradle package task
98100
run: ./gradlew -b ci.gradle package
99101
```
@@ -107,10 +109,11 @@ When using {% data variables.product.prodname_dotcom %}-hosted runners, you can
107109
```yaml{:copy}
108110
steps:
109111
- uses: actions/checkout@v2
110-
- name: Set up JDK 1.8
111-
uses: actions/setup-java@v1
112+
- name: Set up JDK 11
113+
uses: actions/setup-java@v2
112114
with:
113-
java-version: 1.8
115+
java-version: '11'
116+
distribution: 'adopt'
114117
- name: Cache Gradle packages
115118
uses: actions/cache@v2
116119
with:
@@ -143,7 +146,11 @@ Gradle will usually create output files like JARs, EARs, or WARs in the `build/l
143146
```yaml{:copy}
144147
steps:
145148
- uses: actions/checkout@v2
146-
- uses: actions/setup-java@v1
149+
- uses: actions/setup-java@v2
150+
with:
151+
java-version: '11'
152+
distribution: 'adopt'
153+
147154
- run: ./gradlew build
148155
- uses: actions/upload-artifact@v2
149156
with:

content/actions/guides/building-and-testing-java-with-maven.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ jobs:
5858
5959
steps:
6060
- uses: actions/checkout@v2
61-
- name: Set up JDK 1.8
62-
uses: actions/setup-java@v1
61+
- name: Set up JDK 11
62+
uses: actions/setup-java@v2
6363
with:
64-
java-version: 1.8
64+
java-version: '11'
65+
distribution: 'adopt'
6566
- name: Build with Maven
6667
run: mvn --batch-mode --update-snapshots verify
6768
```
@@ -70,7 +71,7 @@ jobs:
7071
This workflow performs the following steps:
7172

7273
1. The `checkout` step downloads a copy of your repository on the runner.
73-
2. The `setup-java` step configures the Java 1.8 JDK.
74+
2. The `setup-java` step configures the Java 11 JDK by Adoptium.
7475
3. The "Build with Maven" step runs the Maven `package` target in non-interactive mode to ensure that your code builds, tests pass, and a package can be created.
7576

7677
The default workflow templates are excellent starting points when creating your build and test workflow, and you can customize the template to suit your project’s needs.
@@ -91,9 +92,10 @@ If you use different commands to build your project, or you want to use a differ
9192
```yaml{:copy}
9293
steps:
9394
- uses: actions/checkout@v2
94-
- uses: actions/setup-java@v1
95+
- uses: actions/setup-java@v2
9596
with:
96-
java-version: 1.8
97+
java-version: '11'
98+
distribution: 'adopt'
9799
- name: Run the Maven verify phase
98100
run: mvn --batch-mode --update-snapshots verify
99101
```
@@ -107,10 +109,11 @@ When using {% data variables.product.prodname_dotcom %}-hosted runners, you can
107109
```yaml{:copy}
108110
steps:
109111
- uses: actions/checkout@v2
110-
- name: Set up JDK 1.8
111-
uses: actions/setup-java@v1
112+
- name: Set up JDK 11
113+
uses: actions/setup-java@v2
112114
with:
113-
java-version: 1.8
115+
java-version: '11'
116+
distribution: 'adopt'
114117
- name: Cache Maven packages
115118
uses: actions/cache@v2
116119
with:
@@ -134,7 +137,10 @@ Maven will usually create output files like JARs, EARs, or WARs in the `target`
134137
```yaml{:copy}
135138
steps:
136139
- uses: actions/checkout@v2
137-
- uses: actions/setup-java@v1
140+
- uses: actions/setup-java@v2
141+
with:
142+
java-version: '11'
143+
distribution: 'adopt'
138144
- run: mvn --batch-mode --update-snapshots verify
139145
- run: mkdir staging && cp target/*.jar staging
140146
- uses: actions/upload-artifact@v2

content/actions/guides/publishing-java-packages-with-gradle.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ jobs:
8585
steps:
8686
- uses: actions/checkout@v2
8787
- name: Set up Java
88-
uses: actions/setup-java@v1
88+
uses: actions/setup-java@v2
8989
with:
90-
java-version: 1.8
90+
java-version: '11'
91+
distribution: 'adopt'
9192
- name: Publish package
9293
run: gradle publish
9394
env:
@@ -143,9 +144,10 @@ jobs:
143144
runs-on: ubuntu-latest
144145
steps:
145146
- uses: actions/checkout@v2
146-
- uses: actions/setup-java@v1
147+
- uses: actions/setup-java@v2
147148
with:
148-
java-version: 1.8
149+
java-version: '11'
150+
distribution: 'adopt'
149151
- name: Publish package
150152
run: gradle publish
151153
env:
@@ -209,9 +211,10 @@ jobs:
209211
steps:
210212
- uses: actions/checkout@v2
211213
- name: Set up Java
212-
uses: actions/setup-java@v1
214+
uses: actions/setup-java@v2
213215
with:
214-
java-version: 1.8
216+
java-version: '11'
217+
distribution: 'adopt'
215218
- name: Publish to the Maven Central Repository
216219
run: gradle publish
217220
env:

content/actions/guides/publishing-java-packages-with-maven.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ jobs:
8585
steps:
8686
- uses: actions/checkout@v2
8787
- name: Set up Maven Central Repository
88-
uses: actions/setup-java@v1
88+
uses: actions/setup-java@v2
8989
with:
90-
java-version: 1.8
90+
java-version: '11'
91+
distribution: 'adopt'
9192
server-id: ossrh
9293
server-username: MAVEN_USERNAME
9394
server-password: MAVEN_PASSWORD
@@ -147,9 +148,10 @@ jobs:
147148
runs-on: ubuntu-latest
148149
steps:
149150
- uses: actions/checkout@v2
150-
- uses: actions/setup-java@v1
151+
- uses: actions/setup-java@v2
151152
with:
152-
java-version: 1.8
153+
java-version: '11'
154+
distribution: 'adopt'
153155
- name: Publish package
154156
run: mvn --batch-mode deploy
155157
env:
@@ -183,9 +185,10 @@ jobs:
183185
steps:
184186
- uses: actions/checkout@v2
185187
- name: Set up Java for publishing to Maven Central Repository
186-
uses: actions/setup-java@v1
188+
uses: actions/setup-java@v2
187189
with:
188-
java-version: 1.8
190+
java-version: '11'
191+
distribution: 'adopt'
189192
server-id: ossrh
190193
server-username: MAVEN_USERNAME
191194
server-password: MAVEN_PASSWORD
@@ -195,9 +198,10 @@ jobs:
195198
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
196199
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
197200
- name: Set up Java for publishing to GitHub Packages
198-
uses: actions/setup-java@v1
201+
uses: actions/setup-java@v2
199202
with:
200-
java-version: 1.8
203+
java-version: '11'
204+
distribution: 'adopt'
201205
- name: Publish to GitHub Packages
202206
run: mvn --batch-mode deploy
203207
env:

data/reusables/github-actions/java-jvm-architecture.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
The starter workflow template sets up the `PATH` to contain OpenJDK 8 for the x64 platform. If you want to use a different version of Java, or target a different architecture (`x64` or `x86`), you can use the `setup-java` action to choose a different Java runtime environment.
44

5-
For example, to use version 9.0.4 of the JDK for the x64 platform, you can use the `setup-java` action and configure the `java-version` and `architecture` parameters to `'9.0.4'` and `x64`.
5+
For example, to use version 11 of the JDK provided by Adoptium for the x64 platform, you can use the `setup-java` action and configure the `java-version`, `distribution` and `architecture` parameters to `'11'`, `'adopt'` and `x64`.
66

77
{% raw %}
88
```yaml{:copy}
99
steps:
1010
- uses: actions/checkout@v2
11-
- name: Set up JDK 9.0.4 for x64
12-
uses: actions/setup-java@v1
11+
- name: Set up JDK 11 for x64
12+
uses: actions/setup-java@v2
1313
with:
14-
java-version: '9.0.4'
14+
java-version: '11'
15+
distribution: 'adopt'
1516
architecture: x64
1617
```
1718
{% endraw %}

0 commit comments

Comments
 (0)