Unverified Commit d854b6da authored by Dmitry Shibanov's avatar Dmitry Shibanov Committed by GitHub
Browse files

Add support for multiple jdks (#368)

parent 749e4491
Loading
Loading
Loading
Loading
+37
Changes for .github/workflows/e2e-versions.yml: 37 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -87,6 +87,43 @@ jobs:
        run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
        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:
    name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
    needs: setup-java-major-minor-versions

File changed.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

+7 −14
Changes for README.md: 7 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -158,25 +158,18 @@ jobs:
```

### Install multiple JDKs
```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
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: 15
      - run: echo "JAVA_15=$JAVA_HOME" >> $GITHUB_ENV
          java-version: |
            8
            11
            15
```

### Advanced
+4
Changes for __tests__/distributors/base-installer.test.ts: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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}`);
+2184 −185

File changed.

Preview size limit exceeded, changes collapsed.

Loading