Skip to content

Commit

Permalink
Add support for multiple jdks (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-shibanov authored Sep 8, 2022
1 parent 749e449 commit d854b6d
Show file tree
Hide file tree
Showing 15 changed files with 5,110 additions and 4,460 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/e2e-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,43 @@ jobs:
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"

This comment has been minimized.

Copy link
@tuckstarrydell
shell: bash

setup-java-multiple-jdks:
name: ${{ matrix.distribution }} ${{ matrix.version }} - multiple jdks - ${{ matrix.os }}
needs: setup-java-major-versions
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version: |
11
17
- name: Verify Java env variables
run: |
$versionsArr = "11","17"
foreach ($version in $versionsArr)
{
$envName = "JAVA_HOME_${version}_${env:RUNNER_ARCH}"
$JavaVersionPath = [Environment]::GetEnvironmentVariable($envName)
if (-not (Test-Path "$JavaVersionPath")) {
Write-Host "$envName is not found"
exit 1
}
}
shell: pwsh
- name: Verify Java
run: bash __tests__/verify-java.sh "17" "${{ steps.setup-java.outputs.path }}"
shell: bash

setup-java-ea-versions-zulu:

This comment has been minimized.

name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
needs: setup-java-major-minor-versions
Expand Down
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/core.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,18 @@ jobs:
```

### Install multiple JDKs

All versions are added to the PATH. The last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}'.

```yaml
steps:
- uses: actions/setup-java@v3
with:
distribution: '<distribution>'
java-version: 8
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV
- uses: actions/setup-java@v3
with:
distribution: '<distribution>'
java-version: 11
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
- uses: actions/setup-java@v3
with:
distribution: '<distribution>'
java-version: 15
- run: echo "JAVA_15=$JAVA_HOME" >> $GITHUB_ENV
java-version: |
8
11
15
```

### Advanced
Expand Down
4 changes: 4 additions & 0 deletions __tests__/distributors/base-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ describe('setupJava', () => {
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
`JAVA_HOME_${input.version}_${input.architecture.toLocaleUpperCase()}`,
expected.path
);
expect(spyCoreSetOutput).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote');
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`);
Expand Down
Loading

0 comments on commit d854b6d

Please sign in to comment.