Skip to content

Commit b6bae37

Browse files
add support for multiple jdks
1 parent 8048bbe commit b6bae37

File tree

10 files changed

+3177
-421
lines changed

10 files changed

+3177
-421
lines changed

.github/workflows/e2e-versions.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,43 @@ jobs:
8787
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
8888
shell: bash
8989

90+
setup-java-multiple-jdks:
91+
name: ${{ matrix.distribution }} ${{ matrix.version }} - multiple jdks - ${{ matrix.os }}
92+
needs: setup-java-major-versions
93+
runs-on: ${{ matrix.os }}
94+
strategy:
95+
fail-fast: false
96+
matrix:
97+
os: [macos-latest, windows-latest, ubuntu-latest]
98+
distribution: ['temurin', 'zulu', 'liberica']
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v3
102+
- name: setup-java
103+
uses: ./
104+
id: setup-java
105+
with:
106+
distribution: ${{ matrix.distribution }}
107+
java-version: |
108+
11
109+
17
110+
- name: Verify Java
111+
run: |
112+
$versionsArr = "11","17"
113+
foreach ($version in $versionsArr)
114+
{
115+
$envName = "JAVA_HOME_${version}_${env:RUNNER_ARCH}"
116+
$JavaVersionPath = [Environment]::GetEnvironmentVariable($envName)
117+
if (-not (Test-Path "$JavaVersionPath")) {
118+
Write-Host "$envName is not found"
119+
exit 1
120+
}
121+
}
122+
shell: pwsh
123+
- name: Verify Java
124+
run: bash __tests__/verify-java.sh "17" "${{ steps.setup-java.outputs.path }}"
125+
shell: bash
126+
90127
setup-java-ea-versions-zulu:
91128
name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
92129
needs: setup-java-major-minor-versions

.licenses/npm/@actions/core.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,10 @@ jobs:
163163
- uses: actions/setup-java@v3
164164
with:
165165
distribution: '<distribution>'
166-
java-version: 8
167-
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV
168-
169-
- uses: actions/setup-java@v3
170-
with:
171-
distribution: '<distribution>'
172-
java-version: 11
173-
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
174-
175-
- uses: actions/setup-java@v3
176-
with:
177-
distribution: '<distribution>'
178-
java-version: 15
179-
- run: echo "JAVA_15=$JAVA_HOME" >> $GITHUB_ENV
166+
java-version: |
167+
8
168+
11
169+
15
180170
```
181171

182172
### Advanced

__tests__/distributors/base-installer.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ describe('setupJava', () => {
244244
expect(spyGetToolcachePath).toHaveBeenCalled();
245245
expect(spyCoreAddPath).toHaveBeenCalled();
246246
expect(spyCoreExportVariable).toHaveBeenCalled();
247+
expect(spyCoreExportVariable).toHaveBeenCalledWith(
248+
`JAVA_HOME_${input.version}_${input.architecture.toLocaleUpperCase()}`,
249+
expected.path
250+
);
247251
expect(spyCoreSetOutput).toHaveBeenCalled();
248252
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote');
249253
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`);

0 commit comments

Comments
 (0)