Compare commits

..

4 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
bfbc448655 Fix prettier formatting in base installer test 2026-06-23 03:09:13 +00:00
Bruno Borges
8b504c3bad Dedupe setJavaDefault and document multi-version/toolchain behavior
- Refactor setJavaDefault to delegate shared output/env logic to
  setJavaEnvironment, avoiding duplication between the two.
- Document that set-default applies to all JDKs in a multiline
  java-version, and that installed JDKs remain registered in Maven
  toolchains regardless of set-default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 03:09:13 +00:00
Guillaume Smet
9eb9a7c9b3 Add set-default option
This option allows to install an additional JDK without making it the
default one.

I have wanted this for quite a long time as I'm running custom GitHub
Actions with Java, which might require a specific JDK and I don't want
to pollute the JDK that is used by the overall workflow calling the
action.
And I'm apparently not alone as there was a preexisting issue.

Fixes #560
2026-06-23 03:09:12 +00:00
copilot-swe-agent[bot]
808209e61e Initial plan 2026-06-23 03:03:52 +00:00
29 changed files with 345 additions and 1075 deletions

View File

@@ -11,9 +11,6 @@ on:
paths-ignore: paths-ignore:
- '**.md' - '**.md'
permissions:
contents: read
jobs: jobs:
call-basic-validation: call-basic-validation:
name: Basic validation name: Basic validation

View File

@@ -11,9 +11,6 @@ on:
- '**.md' - '**.md'
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
jobs: jobs:
call-check-dist: call-check-dist:
name: Check dist/ name: Check dist/

View File

@@ -8,8 +8,6 @@ on:
schedule: schedule:
- cron: '0 3 * * 0' - cron: '0 3 * * 0'
permissions: {}
jobs: jobs:
call-codeQL-analysis: call-codeQL-analysis:
permissions: permissions:

View File

@@ -11,9 +11,6 @@ on:
paths-ignore: paths-ignore:
- '**.md' - '**.md'
permissions:
contents: read
defaults: defaults:
run: run:
shell: bash shell: bash
@@ -28,8 +25,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -57,8 +52,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -84,8 +77,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java

View File

@@ -11,9 +11,6 @@ on:
paths-ignore: paths-ignore:
- '**.md' - '**.md'
permissions:
contents: read
defaults: defaults:
run: run:
shell: bash shell: bash
@@ -28,8 +25,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -56,8 +51,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -81,8 +74,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for maven - name: Run setup-java with the cache for maven
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -107,8 +98,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for maven - name: Run setup-java with the cache for maven
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -136,8 +125,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for sbt - name: Run setup-java with the cache for sbt
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -188,8 +175,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run setup-java with the cache for sbt - name: Run setup-java with the cache for sbt
uses: ./ uses: ./
id: setup-java id: setup-java

View File

@@ -11,9 +11,6 @@ on:
paths-ignore: paths-ignore:
- '**.md' - '**.md'
permissions:
contents: read
jobs: jobs:
setup-java-local-file-adopt: setup-java-local-file-adopt:
name: Validate installation from local file Adopt name: Validate installation from local file Adopt
@@ -25,8 +22,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download Adopt OpenJDK file - name: Download Adopt OpenJDK file
run: | run: |
if ($IsLinux) { if ($IsLinux) {
@@ -51,9 +46,7 @@ jobs:
java-version: '11.0.0-ea' java-version: '11.0.0-ea'
architecture: x64 architecture: x64
- name: Verify Java version - name: Verify Java version
env: run: bash __tests__/verify-java.sh "11.0.10" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "11.0.10" "$JAVA_PATH"
shell: bash shell: bash
setup-java-local-file-zulu: setup-java-local-file-zulu:
@@ -66,8 +59,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download Zulu OpenJDK file - name: Download Zulu OpenJDK file
run: | run: |
if ($IsLinux) { if ($IsLinux) {
@@ -92,9 +83,7 @@ jobs:
java-version: '11.0.0-ea' java-version: '11.0.0-ea'
architecture: x64 architecture: x64
- name: Verify Java version - name: Verify Java version
env: run: bash __tests__/verify-java.sh "11.0" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "11.0" "$JAVA_PATH"
shell: bash shell: bash
setup-java-local-file-temurin: setup-java-local-file-temurin:
@@ -107,8 +96,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download Eclipse Temurin file - name: Download Eclipse Temurin file
run: | run: |
if ($IsLinux) { if ($IsLinux) {
@@ -133,7 +120,5 @@ jobs:
java-version: '11.0.0-ea' java-version: '11.0.0-ea'
architecture: x64 architecture: x64
- name: Verify Java version - name: Verify Java version
env: run: bash __tests__/verify-java.sh "11.0.12" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "11.0.12" "$JAVA_PATH"
shell: bash shell: bash

View File

@@ -11,9 +11,6 @@ on:
paths-ignore: paths-ignore:
- '**.md' - '**.md'
permissions:
contents: read
defaults: defaults:
run: run:
shell: pwsh shell: pwsh
@@ -29,8 +26,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -66,8 +61,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Create fake settings.xml - name: Create fake settings.xml
run: | run: |
$xmlDirectory = Join-Path $HOME ".m2" $xmlDirectory = Join-Path $HOME ".m2"
@@ -104,8 +97,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Create fake settings.xml - name: Create fake settings.xml
run: | run: |
$xmlDirectory = Join-Path $HOME ".m2" $xmlDirectory = Join-Path $HOME ".m2"
@@ -143,8 +134,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java

View File

@@ -13,10 +13,6 @@ on:
schedule: schedule:
- cron: '0 */12 * * *' - cron: '0 */12 * * *'
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
jobs: jobs:
setup-java-major-versions: setup-java-major-versions:
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
@@ -78,8 +74,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -89,17 +83,14 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
JAVA_VERSION: ${{ matrix.version }}
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
shell: bash shell: bash
setup-java-alpine-linux: setup-java-alpine-linux:
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - alpine-linux - ${{ matrix.os }} name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - alpine-linux - ${{ matrix.os }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
container: container:
image: alpine:3.21 image: alpine:latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@@ -109,8 +100,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Install bash - name: Install bash
run: apk add --no-cache bash run: apk add --no-cache bash
- name: setup-java - name: setup-java
@@ -120,10 +109,7 @@ jobs:
java-version: ${{ matrix.version }} java-version: ${{ matrix.version }}
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
JAVA_VERSION: ${{ matrix.version }}
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
shell: bash shell: bash
setup-java-major-minor-versions: setup-java-major-minor-versions:
@@ -164,8 +150,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -173,12 +157,10 @@ jobs:
java-version: ${{ matrix.version }} java-version: ${{ matrix.version }}
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
JAVA_VERSION: ${{ matrix.version }}
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
shell: bash shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
setup-java-check-latest: setup-java-check-latest:
name: ${{ matrix.distribution }} ${{ matrix.version }} - check-latest flag - ${{ matrix.os }} name: ${{ matrix.distribution }} ${{ matrix.version }} - check-latest flag - ${{ matrix.os }}
@@ -203,8 +185,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -215,9 +195,7 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "11" "$JAVA_PATH"
shell: bash shell: bash
setup-java-multiple-jdks: setup-java-multiple-jdks:
@@ -243,8 +221,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -269,9 +245,7 @@ jobs:
} }
shell: pwsh shell: pwsh
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "17" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "17" "$JAVA_PATH"
shell: bash shell: bash
setup-java-ea-versions-zulu: setup-java-ea-versions-zulu:
@@ -286,8 +260,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -295,10 +267,7 @@ jobs:
java-version: ${{ matrix.version }} java-version: ${{ matrix.version }}
distribution: zulu distribution: zulu
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
JAVA_VERSION: ${{ matrix.version }}
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
shell: bash shell: bash
setup-java-ea-versions-temurin: setup-java-ea-versions-temurin:
@@ -313,8 +282,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -322,10 +289,7 @@ jobs:
java-version: ${{ matrix.version }} java-version: ${{ matrix.version }}
distribution: temurin distribution: temurin
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
JAVA_VERSION: ${{ matrix.version }}
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
shell: bash shell: bash
setup-java-ea-versions-sapmachine: setup-java-ea-versions-sapmachine:
@@ -340,8 +304,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -349,10 +311,7 @@ jobs:
java-version: ${{ matrix.version }} java-version: ${{ matrix.version }}
distribution: sapmachine distribution: sapmachine
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
JAVA_VERSION: ${{ matrix.version }}
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
shell: bash shell: bash
setup-java-custom-package-type: setup-java-custom-package-type:
@@ -432,8 +391,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -444,10 +401,7 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
JAVA_VERSION: ${{ matrix.version }}
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
shell: bash shell: bash
# Only Liberica and Zulu provide x86 # Only Liberica and Zulu provide x86
@@ -465,8 +419,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@@ -475,10 +427,7 @@ jobs:
java-version: ${{ matrix.version }} java-version: ${{ matrix.version }}
architecture: 'x86' architecture: 'x86'
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
JAVA_VERSION: ${{ matrix.version }}
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
shell: bash shell: bash
setup-java-version-both-version-inputs-presents: setup-java-version-both-version-inputs-presents:
@@ -493,8 +442,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Create .java-version file - name: Create .java-version file
shell: bash shell: bash
run: echo "17" > .java-version run: echo "17" > .java-version
@@ -509,9 +456,7 @@ jobs:
java-version: 11 java-version: 11
java-version-file: ${{matrix.java-version-file }} java-version-file: ${{matrix.java-version-file }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "11" "$JAVA_PATH"
shell: bash shell: bash
setup-java-version-from-file-major-notation: setup-java-version-from-file-major-notation:
@@ -526,8 +471,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Create .java-version file - name: Create .java-version file
shell: bash shell: bash
run: echo "11" > .java-version run: echo "11" > .java-version
@@ -541,9 +484,7 @@ jobs:
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
java-version-file: ${{matrix.java-version-file }} java-version-file: ${{matrix.java-version-file }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "11" "$JAVA_PATH"
shell: bash shell: bash
setup-java-version-from-file-major-minor-patch-notation: setup-java-version-from-file-major-minor-patch-notation:
@@ -558,8 +499,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Create .java-version file - name: Create .java-version file
shell: bash shell: bash
run: echo "17.0.10" > .java-version run: echo "17.0.10" > .java-version
@@ -573,9 +512,7 @@ jobs:
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
java-version-file: ${{matrix.java-version-file }} java-version-file: ${{matrix.java-version-file }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "17.0.10" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
run: bash __tests__/verify-java.sh "17.0.10" "$JAVA_PATH"
shell: bash shell: bash
setup-java-version-from-file-major-minor-patch-with-dist: setup-java-version-from-file-major-minor-patch-with-dist:
@@ -590,8 +527,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Create .java-version file - name: Create .java-version file
shell: bash shell: bash
run: echo "openjdk64-17.0.10" > .java-version run: echo "openjdk64-17.0.10" > .java-version
@@ -608,7 +543,79 @@ jobs:
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
java-version-file: ${{matrix.java-version-file }} java-version-file: ${{matrix.java-version-file }}
- name: Verify Java - name: Verify Java
env: run: bash __tests__/verify-java.sh "17.0.10" "${{ steps.setup-java.outputs.path }}"
JAVA_PATH: ${{ steps.setup-java.outputs.path }} shell: bash
run: bash __tests__/verify-java.sh "17.0.10" "$JAVA_PATH"
setup-java-set-default:
name: set-default option - ${{ matrix.os }}
needs: setup-java-major-versions
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Java 17 as default
uses: ./
id: setup-java-17
with:
distribution: 'temurin'
java-version: '17'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Java 21 without setting as default
uses: ./
id: setup-java-21
with:
distribution: 'temurin'
java-version: '21'
set-default: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify JAVA_HOME still points to Java 17
run: |
echo "JAVA_HOME=$JAVA_HOME"
echo "Java 17 path=${{ steps.setup-java-17.outputs.path }}"
if [ "$JAVA_HOME" != "${{ steps.setup-java-17.outputs.path }}" ]; then
echo "JAVA_HOME should still point to Java 17"
exit 1
fi
shell: bash
- name: Verify java -version reports Java 17
run: |
JAVA_VERSION=$(java -version 2>&1 | head -1)
echo "java -version: $JAVA_VERSION"
if ! echo "$JAVA_VERSION" | grep -q "17"; then
echo "Default java should still be version 17"
exit 1
fi
shell: bash
- name: Verify JAVA_HOME_21 env var is set
run: |
$envName = "JAVA_HOME_21_${env:RUNNER_ARCH}"
$JavaVersionPath = [Environment]::GetEnvironmentVariable($envName)
if (-not $JavaVersionPath) {
Write-Host "$envName is not set"
exit 1
}
if (-not (Test-Path "$JavaVersionPath")) {
Write-Host "$envName path does not exist: $JavaVersionPath"
exit 1
}
Write-Host "$envName=$JavaVersionPath"
shell: pwsh
- name: Verify Java 21 outputs are set
run: |
echo "Java 21 path=${{ steps.setup-java-21.outputs.path }}"
echo "Java 21 version=${{ steps.setup-java-21.outputs.version }}"
if [ -z "${{ steps.setup-java-21.outputs.path }}" ]; then
echo "Java 21 path output should be set"
exit 1
fi
if [ -z "${{ steps.setup-java-21.outputs.version }}" ]; then
echo "Java 21 version output should be set"
exit 1
fi
shell: bash shell: bash

View File

@@ -9,9 +9,6 @@ on:
- main - main
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
jobs: jobs:
call-licensed: call-licensed:
name: Licensed name: Licensed

View File

@@ -5,8 +5,6 @@ on:
types: [released] types: [released]
workflow_dispatch: workflow_dispatch:
permissions: {}
jobs: jobs:
publish: publish:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -18,8 +16,6 @@ jobs:
steps: steps:
- name: Checking out - name: Checking out
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Publish - name: Publish
id: publish id: publish
uses: actions/publish-immutable-action@v0.0.4 uses: actions/publish-immutable-action@v0.0.4

View File

@@ -5,12 +5,7 @@ on:
- cron: '0 3 * * 0' - cron: '0 3 * * 0'
workflow_dispatch: workflow_dispatch:
permissions: {}
jobs: jobs:
call-update-configuration-files: call-update-configuration-files:
name: Update configuration files name: Update configuration files
permissions:
contents: write # to push the branch with updated configuration files
pull-requests: write # to open/update the configuration update PR
uses: actions/reusable-workflows/.github/workflows/update-config-files.yml@main uses: actions/reusable-workflows/.github/workflows/update-config-files.yml@main

View File

@@ -1,48 +0,0 @@
name: Security analysis with zizmor
on:
push:
branches:
- main
- releases/*
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
permissions: {}
jobs:
zizmor:
name: Analyze workflows with zizmor
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write # to upload SARIF results to code scanning
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install zizmor
run: pip install zizmor
- name: Run zizmor
run: zizmor --format sarif .github/workflows/ > zizmor.sarif
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload SARIF results to code scanning
if: always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: zizmor.sarif
category: zizmor

11
.github/zizmor.yml vendored
View File

@@ -1,11 +0,0 @@
# Configuration for zizmor (https://docs.zizmor.sh)
rules:
unpinned-uses:
config:
# First-party GitHub-maintained actions are trusted and referenced by
# major-version tags (the convention used across the actions org).
# Any third-party action must be pinned to a full commit SHA.
policies:
actions/*: ref-pin
github/*: ref-pin
'*': hash-pin

View File

@@ -41,6 +41,8 @@ For more details, see the full release notes on the [releases page](https://git
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec. - `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
- `set-default`: Set to `false` to install a JDK without making it the default. When `false`, `JAVA_HOME` and `PATH` are not updated, but `JAVA_HOME_<major>_<arch>` is still set so the JDK remains discoverable. Default value: `true`. See [Installing JDK without setting as default](docs/advanced-usage.md#Installing-JDK-without-setting-as-default) for more details.
- `cache`: Quick [setup caching](#caching-packages-dependencies) for the dependencies managed through one of the predefined package managers. It can be one of "maven", "gradle" or "sbt". - `cache`: Quick [setup caching](#caching-packages-dependencies) for the dependencies managed through one of the predefined package managers. It can be one of "maven", "gradle" or "sbt".
- `cache-dependency-path`: The path to a dependency file: pom.xml, build.gradle, build.sbt, etc. This option can be used with the `cache` option. If this option is omitted, the action searches for the dependency file in the entire repository. This option supports wildcards and a list of file names for caching multiple dependencies. - `cache-dependency-path`: The path to a dependency file: pom.xml, build.gradle, build.sbt, etc. This option can be used with the `cache` option. If this option is omitted, the action searches for the dependency file in the entire repository. This option supports wildcards and a list of file names for caching multiple dependencies.
@@ -112,7 +114,6 @@ Currently, the following distributions are supported:
| `dragonwell` | [Alibaba Dragonwell JDK](https://dragonwell-jdk.io/) | [`dragonwell` license](https://www.aliyun.com/product/dragonwell/) | `dragonwell` | [Alibaba Dragonwell JDK](https://dragonwell-jdk.io/) | [`dragonwell` license](https://www.aliyun.com/product/dragonwell/)
| `sapmachine` | [SAP SapMachine JDK/JRE](https://sapmachine.io/) | [`sapmachine` license](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE) | `sapmachine` | [SAP SapMachine JDK/JRE](https://sapmachine.io/) | [`sapmachine` license](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
| `graalvm` | [Oracle GraalVM](https://www.graalvm.org/) | [`graalvm` license](https://www.oracle.com/downloads/licenses/graal-free-license.html) | `graalvm` | [Oracle GraalVM](https://www.graalvm.org/) | [`graalvm` license](https://www.oracle.com/downloads/licenses/graal-free-license.html)
| `graalvm-community` | [GraalVM Community](https://github.com/graalvm/graalvm-ce-builds/releases) | [`graalvm-community` license](https://github.com/oracle/graal/blob/master/LICENSE)
| `jetbrains` | [JetBrains Runtime](https://github.com/JetBrains/JetBrainsRuntime/) | [`jetbrains` license](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE) | `jetbrains` | [JetBrains Runtime](https://github.com/JetBrains/JetBrainsRuntime/) | [`jetbrains` license](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE)
| `jdkfile` | Custom JDK Installation | | | `jdkfile` | Custom JDK Installation | |
@@ -121,7 +122,6 @@ Currently, the following distributions are supported:
> - AdoptOpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` and `adopt-openj9`, to `temurin` and `semeru` respectively, to keep receiving software and security updates. See more details in the [Good-bye AdoptOpenJDK post](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/). > - AdoptOpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` and `adopt-openj9`, to `temurin` and `semeru` respectively, to keep receiving software and security updates. See more details in the [Good-bye AdoptOpenJDK post](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/).
> - For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness. > - For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
> - To comply with the GraalVM Free Terms and Conditions (GFTC) license, it is recommended to use GraalVM JDK 17 version 17.0.12, as this is the only version of GraalVM JDK 17 available under the GFTC license. Additionally, it is encouraged to consider upgrading to GraalVM JDK 21, which offers the latest features and improvements. > - To comply with the GraalVM Free Terms and Conditions (GFTC) license, it is recommended to use GraalVM JDK 17 version 17.0.12, as this is the only version of GraalVM JDK 17 available under the GFTC license. Additionally, it is encouraged to consider upgrading to GraalVM JDK 21, which offers the latest features and improvements.
> - GraalVM Community is available as `distribution: 'graalvm-community'` for stable JDK 17 and later releases published on GitHub.
**NOTE:** Oracle JDK 17 licensing varies by patch level. As shown on the [JDK 17 Archive](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) (versions up to 17.0.12 are under the [NFTC](https://www.oracle.com/downloads/licenses/no-fee-license.html) license) and the [JDK 17.0.13+ Archive](https://www.oracle.com/java/technologies/javase/jdk17-0-13-later-archive-downloads.html) (versions 17.0.13 and later are under the [OTN](https://www.oracle.com/downloads/licenses/javase-license1.html) license). To stay on the free NFTC license, use `distribution: 'oracle'` with `java-version: '17.0.12'` (or earlier) instead of the floating `'17'`. Alternatively, upgrade to Oracle JDK 21+, which remains under the NFTC license. **NOTE:** Oracle JDK 17 licensing varies by patch level. As shown on the [JDK 17 Archive](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) (versions up to 17.0.12 are under the [NFTC](https://www.oracle.com/downloads/licenses/no-fee-license.html) license) and the [JDK 17.0.13+ Archive](https://www.oracle.com/java/technologies/javase/jdk17-0-13-later-archive-downloads.html) (versions 17.0.13 and later are under the [OTN](https://www.oracle.com/downloads/licenses/javase-license1.html) license). To stay on the free NFTC license, use `distribution: 'oracle'` with `java-version: '17.0.12'` (or earlier) instead of the floating `'17'`. Alternatively, upgrade to Oracle JDK 21+, which remains under the NFTC license.

View File

@@ -545,6 +545,110 @@ describe('setupJava', () => {
expect(spyCoreExportVariable).not.toHaveBeenCalled(); expect(spyCoreExportVariable).not.toHaveBeenCalled();
expect(spyCoreSetOutput).not.toHaveBeenCalled(); expect(spyCoreSetOutput).not.toHaveBeenCalled();
}); });
it('should not set JAVA_HOME and PATH when setDefault is false', async () => {
mockJavaBase = new EmptyJavaBase({
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false,
setDefault: false
});
await expect(mockJavaBase.setupJava()).resolves.toEqual({
version: installedJavaVersion,
path: javaPath
});
expect(spyCoreExportVariable).not.toHaveBeenCalledWith(
'JAVA_HOME',
expect.anything()
);
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'JAVA_HOME_11_X86',
javaPath
);
expect(spyCoreSetOutput).toHaveBeenCalledWith(
'version',
installedJavaVersion
);
expect(spyCoreSetOutput).toHaveBeenCalledWith('path', javaPath);
expect(spyCoreSetOutput).toHaveBeenCalledWith('distribution', 'Empty');
expect(spyCoreInfo).toHaveBeenCalledWith(
`Installing Java ${installedJavaVersion} (not setting as default)`
);
});
it('should set JAVA_HOME and PATH when setDefault is true', async () => {
mockJavaBase = new EmptyJavaBase({
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false,
setDefault: true
});
await expect(mockJavaBase.setupJava()).resolves.toEqual({
version: installedJavaVersion,
path: javaPath
});
expect(spyCoreExportVariable).toHaveBeenCalledWith('JAVA_HOME', javaPath);
expect(spyCoreAddPath).toHaveBeenCalledWith(path.join(javaPath, 'bin'));
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'JAVA_HOME_11_X86',
javaPath
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Setting Java ${installedJavaVersion} as the default`
);
});
it('should default to setting as default when setDefault is not specified', async () => {
mockJavaBase = new EmptyJavaBase({
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
await expect(mockJavaBase.setupJava()).resolves.toEqual({
version: installedJavaVersion,
path: javaPath
});
expect(spyCoreExportVariable).toHaveBeenCalledWith('JAVA_HOME', javaPath);
expect(spyCoreAddPath).toHaveBeenCalledWith(path.join(javaPath, 'bin'));
expect(spyCoreInfo).toHaveBeenCalledWith(
`Setting Java ${installedJavaVersion} as the default`
);
});
it('should download and not set default when setDefault is false', async () => {
mockJavaBase = new EmptyJavaBase({
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false,
setDefault: false
});
await expect(mockJavaBase.setupJava()).resolves.toEqual({
version: '11.0.9',
path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64')
});
expect(spyCoreExportVariable).not.toHaveBeenCalledWith(
'JAVA_HOME',
expect.anything()
);
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'JAVA_HOME_11_X64',
path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64')
);
expect(spyCoreSetOutput).toHaveBeenCalledWith('version', '11.0.9');
expect(spyCoreSetOutput).toHaveBeenCalledWith(
'path',
path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64')
);
expect(spyCoreInfo).toHaveBeenCalledWith(
'Installing Java 11.0.9 (not setting as default)'
);
});
}); });
describe('normalizeVersion', () => { describe('normalizeVersion', () => {

View File

@@ -3,11 +3,7 @@ import * as tc from '@actions/tool-cache';
import * as http from '@actions/http-client'; import * as http from '@actions/http-client';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
GraalVMCommunityDistribution,
GraalVMDistribution
} from '../../src/distributions/graalvm/installer';
import {getJavaDistribution} from '../../src/distributions/distribution-factory';
import {JavaInstallerOptions} from '../../src/distributions/base-models'; import {JavaInstallerOptions} from '../../src/distributions/base-models';
import * as util from '../../src/util'; import * as util from '../../src/util';
@@ -45,7 +41,6 @@ beforeAll(() => {
describe('GraalVMDistribution', () => { describe('GraalVMDistribution', () => {
let distribution: GraalVMDistribution; let distribution: GraalVMDistribution;
let communityDistribution: GraalVMCommunityDistribution;
let mockHttpClient: jest.Mocked<http.HttpClient>; let mockHttpClient: jest.Mocked<http.HttpClient>;
let spyCoreError: jest.SpyInstance; let spyCoreError: jest.SpyInstance;
@@ -60,11 +55,9 @@ describe('GraalVMDistribution', () => {
jest.clearAllMocks(); jest.clearAllMocks();
distribution = new GraalVMDistribution(defaultOptions); distribution = new GraalVMDistribution(defaultOptions);
communityDistribution = new GraalVMCommunityDistribution(defaultOptions);
mockHttpClient = new http.HttpClient() as jest.Mocked<http.HttpClient>; mockHttpClient = new http.HttpClient() as jest.Mocked<http.HttpClient>;
(distribution as any).http = mockHttpClient; (distribution as any).http = mockHttpClient;
(communityDistribution as any).http = mockHttpClient;
(util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz'); (util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz');
@@ -249,23 +242,6 @@ describe('GraalVMDistribution', () => {
path: '/cached/java/path' path: '/cached/java/path'
}); });
}); });
it('should use a dedicated toolcache folder for GraalVM Community', async () => {
const result = await (communityDistribution as any).downloadTool(
javaRelease
);
expect(tc.cacheDir).toHaveBeenCalledWith(
path.join('/tmp/extracted', 'graalvm-jdk-17.0.5'),
'Java_GraalVM_Community_jdk',
'17.0.5',
'x64'
);
expect(result).toEqual({
version: '17.0.5',
path: '/cached/java/path'
});
});
}); });
describe('findPackageForDownload', () => { describe('findPackageForDownload', () => {
@@ -972,121 +948,5 @@ describe('GraalVMDistribution', () => {
configurable: true configurable: true
}); });
}); });
describe('GraalVMCommunityDistribution', () => {
beforeEach(() => {
jest
.spyOn(communityDistribution, 'getPlatform')
.mockReturnValue('linux');
});
it('should resolve an exact GraalVM Community version from GitHub releases', async () => {
mockHttpClient.getJson.mockResolvedValue({
result: [
{
draft: false,
prerelease: false,
assets: [
{
name: 'graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
browser_download_url:
'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz'
}
]
}
],
statusCode: 200,
headers: {}
});
const result = await (
communityDistribution as any
).findPackageForDownload('21.0.2');
expect(result).toEqual({
url: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
version: '21.0.2'
});
});
it('should resolve the latest GraalVM Community release for a major version', async () => {
mockHttpClient.getJson.mockResolvedValue({
result: [
{
draft: false,
prerelease: false,
assets: [
{
name: 'graalvm-community-jdk-21.0.1_linux-x64_bin.tar.gz',
browser_download_url:
'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.1/graalvm-community-jdk-21.0.1_linux-x64_bin.tar.gz'
}
]
},
{
draft: false,
prerelease: false,
assets: [
{
name: 'graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
browser_download_url:
'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz'
}
]
}
],
statusCode: 200,
headers: {}
});
const result = await (
communityDistribution as any
).findPackageForDownload('21');
expect(result).toEqual({
url: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
version: '21.0.2'
});
});
it('should reject GraalVM Community early access requests', async () => {
(communityDistribution as any).stable = false;
await expect(
(communityDistribution as any).findPackageForDownload('23')
).rejects.toThrow(
'GraalVM Community does not provide early access builds'
);
});
it('should surface an error when the releases listing is not an array', async () => {
mockHttpClient.getJson.mockResolvedValue({
result: {message: 'API rate limit exceeded'},
statusCode: 403,
headers: {}
});
await expect(
(communityDistribution as any).findPackageForDownload('21')
).rejects.toThrow(
/Unexpected response while listing GraalVM Community releases.*HTTP status code: 403/s
);
});
});
});
});
describe('distribution factory', () => {
const defaultOptions: JavaInstallerOptions = {
version: '17',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
};
it('should map graalvm-community to the community installer', () => {
const community = getJavaDistribution('graalvm-community', defaultOptions);
expect(community).toBeInstanceOf(GraalVMCommunityDistribution);
}); });
}); });

View File

@@ -1,104 +0,0 @@
import * as core from '@actions/core';
import {configureMavenArgs} from '../src/maven-args';
import {
INPUT_SHOW_DOWNLOAD_PROGRESS,
MAVEN_ARGS_ENV,
MAVEN_NO_TRANSFER_PROGRESS_FLAG
} from '../src/constants';
describe('configureMavenArgs', () => {
let inputs: Record<string, string>;
let spyGetInput: jest.SpyInstance;
let spyExportVariable: jest.SpyInstance;
let spyInfo: jest.SpyInstance;
let spyDebug: jest.SpyInstance;
const originalMavenArgs = process.env[MAVEN_ARGS_ENV];
beforeEach(() => {
inputs = {};
spyGetInput = jest.spyOn(core, 'getInput');
spyGetInput.mockImplementation((name: string) => inputs[name] ?? '');
spyExportVariable = jest.spyOn(core, 'exportVariable');
spyExportVariable.mockImplementation((name: string, value: string) => {
process.env[name] = value;
});
spyInfo = jest.spyOn(core, 'info');
spyInfo.mockImplementation(() => undefined);
spyDebug = jest.spyOn(core, 'debug');
spyDebug.mockImplementation(() => undefined);
delete process.env[MAVEN_ARGS_ENV];
});
afterEach(() => {
jest.restoreAllMocks();
if (originalMavenArgs === undefined) {
delete process.env[MAVEN_ARGS_ENV];
} else {
process.env[MAVEN_ARGS_ENV] = originalMavenArgs;
}
});
it('sets MAVEN_ARGS with -ntp by default', () => {
configureMavenArgs();
expect(spyExportVariable).toHaveBeenCalledWith(
MAVEN_ARGS_ENV,
MAVEN_NO_TRANSFER_PROGRESS_FLAG
);
expect(process.env[MAVEN_ARGS_ENV]).toBe(MAVEN_NO_TRANSFER_PROGRESS_FLAG);
});
it('does not modify MAVEN_ARGS when show-download-progress is true', () => {
inputs[INPUT_SHOW_DOWNLOAD_PROGRESS] = 'true';
configureMavenArgs();
expect(spyExportVariable).not.toHaveBeenCalled();
expect(process.env[MAVEN_ARGS_ENV]).toBeUndefined();
});
it('preserves an existing MAVEN_ARGS value and appends -ntp', () => {
process.env[MAVEN_ARGS_ENV] = '-B -Dstyle.color=always';
configureMavenArgs();
expect(spyExportVariable).toHaveBeenCalledWith(
MAVEN_ARGS_ENV,
`-B -Dstyle.color=always ${MAVEN_NO_TRANSFER_PROGRESS_FLAG}`
);
});
it('does not duplicate the flag when -ntp is already present', () => {
process.env[MAVEN_ARGS_ENV] = '-B -ntp';
configureMavenArgs();
expect(spyExportVariable).not.toHaveBeenCalled();
expect(process.env[MAVEN_ARGS_ENV]).toBe('-B -ntp');
});
it('does not duplicate the flag when --no-transfer-progress is already present', () => {
process.env[MAVEN_ARGS_ENV] = '--no-transfer-progress -B';
configureMavenArgs();
expect(spyExportVariable).not.toHaveBeenCalled();
expect(process.env[MAVEN_ARGS_ENV]).toBe('--no-transfer-progress -B');
});
it('keeps the existing MAVEN_ARGS when show-download-progress is true', () => {
inputs[INPUT_SHOW_DOWNLOAD_PROGRESS] = 'true';
process.env[MAVEN_ARGS_ENV] = '-B';
configureMavenArgs();
expect(spyExportVariable).not.toHaveBeenCalled();
expect(process.env[MAVEN_ARGS_ENV]).toBe('-B');
});
});

View File

@@ -26,6 +26,10 @@ inputs:
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec' description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
required: false required: false
default: false default: false
set-default:
description: 'Set this option to false if you want to install a JDK but not make it the default. When false, JAVA_HOME and PATH are not updated, but JAVA_HOME_<major>_<arch> is still set.'
required: false
default: true
server-id: server-id:
description: 'ID of the distributionManagement repository in the pom.xml description: 'ID of the distributionManagement repository in the pom.xml
file. Default is `github`' file. Default is `github`'
@@ -75,10 +79,6 @@ inputs:
mvn-toolchain-vendor: mvn-toolchain-vendor:
description: 'Name of Maven Toolchain Vendor if the default name of "${distribution}" is not wanted. See examples of supported syntax in Advanced Usage file' description: 'Name of Maven Toolchain Vendor if the default name of "${distribution}" is not wanted. See examples of supported syntax in Advanced Usage file'
required: false required: false
show-download-progress:
description: 'Whether Maven should print artifact download/transfer progress to the build log. When "false" (default) the action sets "-ntp" (--no-transfer-progress) in MAVEN_ARGS to produce cleaner logs. Set to "true" to keep the progress output. Has no effect on non-Maven builds.'
required: false
default: false
outputs: outputs:
distribution: distribution:
description: 'Distribution of Java that has been installed' description: 'Distribution of Java that has been installed'

View File

@@ -52241,7 +52241,7 @@ else {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = exports.MAVEN_ARGS_ENV = exports.INPUT_SHOW_DOWNLOAD_PROGRESS = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_SET_DEFAULT = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
exports.INPUT_JAVA_VERSION = 'java-version'; exports.INPUT_JAVA_VERSION = 'java-version';
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file'; exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
@@ -52250,6 +52250,7 @@ exports.INPUT_JAVA_PACKAGE = 'java-package';
exports.INPUT_DISTRIBUTION = 'distribution'; exports.INPUT_DISTRIBUTION = 'distribution';
exports.INPUT_JDK_FILE = 'jdkFile'; exports.INPUT_JDK_FILE = 'jdkFile';
exports.INPUT_CHECK_LATEST = 'check-latest'; exports.INPUT_CHECK_LATEST = 'check-latest';
exports.INPUT_SET_DEFAULT = 'set-default';
exports.INPUT_SERVER_ID = 'server-id'; exports.INPUT_SERVER_ID = 'server-id';
exports.INPUT_SERVER_USERNAME = 'server-username'; exports.INPUT_SERVER_USERNAME = 'server-username';
exports.INPUT_SERVER_PASSWORD = 'server-password'; exports.INPUT_SERVER_PASSWORD = 'server-password';
@@ -52268,10 +52269,6 @@ exports.MVN_SETTINGS_FILE = 'settings.xml';
exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml';
exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
exports.INPUT_SHOW_DOWNLOAD_PROGRESS = 'show-download-progress';
exports.MAVEN_ARGS_ENV = 'MAVEN_ARGS';
exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = '-ntp';
exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = '--no-transfer-progress';
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];

262
dist/setup/index.js vendored
View File

@@ -78000,7 +78000,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = exports.MAVEN_ARGS_ENV = exports.INPUT_SHOW_DOWNLOAD_PROGRESS = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_SET_DEFAULT = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
exports.INPUT_JAVA_VERSION = 'java-version'; exports.INPUT_JAVA_VERSION = 'java-version';
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file'; exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
@@ -78009,6 +78009,7 @@ exports.INPUT_JAVA_PACKAGE = 'java-package';
exports.INPUT_DISTRIBUTION = 'distribution'; exports.INPUT_DISTRIBUTION = 'distribution';
exports.INPUT_JDK_FILE = 'jdkFile'; exports.INPUT_JDK_FILE = 'jdkFile';
exports.INPUT_CHECK_LATEST = 'check-latest'; exports.INPUT_CHECK_LATEST = 'check-latest';
exports.INPUT_SET_DEFAULT = 'set-default';
exports.INPUT_SERVER_ID = 'server-id'; exports.INPUT_SERVER_ID = 'server-id';
exports.INPUT_SERVER_USERNAME = 'server-username'; exports.INPUT_SERVER_USERNAME = 'server-username';
exports.INPUT_SERVER_PASSWORD = 'server-password'; exports.INPUT_SERVER_PASSWORD = 'server-password';
@@ -78027,10 +78028,6 @@ exports.MVN_SETTINGS_FILE = 'settings.xml';
exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml';
exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
exports.INPUT_SHOW_DOWNLOAD_PROGRESS = 'show-download-progress';
exports.MAVEN_ARGS_ENV = 'MAVEN_ARGS';
exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = '-ntp';
exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = '--no-transfer-progress';
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];
@@ -78321,6 +78318,10 @@ class JavaBase {
this.architecture = installerOptions.architecture || os_1.default.arch(); this.architecture = installerOptions.architecture || os_1.default.arch();
this.packageType = installerOptions.packageType; this.packageType = installerOptions.packageType;
this.checkLatest = installerOptions.checkLatest; this.checkLatest = installerOptions.checkLatest;
this.setDefault =
installerOptions.setDefault !== undefined
? installerOptions.setDefault
: true;
} }
setupJava() { setupJava() {
var _a, _b; var _a, _b;
@@ -78436,8 +78437,14 @@ class JavaBase {
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) { if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
foundJava.path = macOSPostfixPath; foundJava.path = macOSPostfixPath;
} }
if (this.setDefault) {
core.info(`Setting Java ${foundJava.version} as the default`); core.info(`Setting Java ${foundJava.version} as the default`);
this.setJavaDefault(foundJava.version, foundJava.path); this.setJavaDefault(foundJava.version, foundJava.path);
}
else {
core.info(`Installing Java ${foundJava.version} (not setting as default)`);
this.setJavaEnvironment(foundJava.version, foundJava.path);
}
return foundJava; return foundJava;
}); });
} }
@@ -78535,9 +78542,12 @@ class JavaBase {
return error; return error;
} }
setJavaDefault(version, toolPath) { setJavaDefault(version, toolPath) {
const majorVersion = version.split('.')[0];
core.exportVariable('JAVA_HOME', toolPath); core.exportVariable('JAVA_HOME', toolPath);
core.addPath(path_1.default.join(toolPath, 'bin')); core.addPath(path_1.default.join(toolPath, 'bin'));
this.setJavaEnvironment(version, toolPath);
}
setJavaEnvironment(version, toolPath) {
const majorVersion = version.split('.')[0];
core.setOutput('distribution', this.distribution); core.setOutput('distribution', this.distribution);
core.setOutput('path', toolPath); core.setOutput('path', toolPath);
core.setOutput('version', version); core.setOutput('version', version);
@@ -78775,7 +78785,6 @@ var JavaDistribution;
JavaDistribution["Dragonwell"] = "dragonwell"; JavaDistribution["Dragonwell"] = "dragonwell";
JavaDistribution["SapMachine"] = "sapmachine"; JavaDistribution["SapMachine"] = "sapmachine";
JavaDistribution["GraalVM"] = "graalvm"; JavaDistribution["GraalVM"] = "graalvm";
JavaDistribution["GraalVMCommunity"] = "graalvm-community";
JavaDistribution["JetBrains"] = "jetbrains"; JavaDistribution["JetBrains"] = "jetbrains";
})(JavaDistribution || (JavaDistribution = {})); })(JavaDistribution || (JavaDistribution = {}));
function getJavaDistribution(distributionName, installerOptions, jdkFile) { function getJavaDistribution(distributionName, installerOptions, jdkFile) {
@@ -78807,8 +78816,6 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
return new installer_11.SapMachineDistribution(installerOptions); return new installer_11.SapMachineDistribution(installerOptions);
case JavaDistribution.GraalVM: case JavaDistribution.GraalVM:
return new installer_12.GraalVMDistribution(installerOptions); return new installer_12.GraalVMDistribution(installerOptions);
case JavaDistribution.GraalVMCommunity:
return new installer_12.GraalVMCommunityDistribution(installerOptions);
case JavaDistribution.JetBrains: case JavaDistribution.JetBrains:
return new installer_13.JetBrainsDistribution(installerOptions); return new installer_13.JetBrainsDistribution(installerOptions);
default: default:
@@ -79076,29 +79083,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GraalVMCommunityDistribution = exports.GraalVMDistribution = void 0; exports.GraalVMDistribution = void 0;
const core = __importStar(__nccwpck_require__(37484)); const core = __importStar(__nccwpck_require__(37484));
const tc = __importStar(__nccwpck_require__(33472)); const tc = __importStar(__nccwpck_require__(33472));
const fs_1 = __importDefault(__nccwpck_require__(79896)); const fs_1 = __importDefault(__nccwpck_require__(79896));
const path_1 = __importDefault(__nccwpck_require__(16928)); const path_1 = __importDefault(__nccwpck_require__(16928));
const semver_1 = __importDefault(__nccwpck_require__(62088));
const base_installer_1 = __nccwpck_require__(79935); const base_installer_1 = __nccwpck_require__(79935);
const http_client_1 = __nccwpck_require__(54844); const http_client_1 = __nccwpck_require__(54844);
const util_1 = __nccwpck_require__(54527); const util_1 = __nccwpck_require__(54527);
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm'; const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/'; const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
const GRAALVM_COMMUNITY_RELEASES_URL = 'https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=100';
const GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN = 'https://api.github.com';
const GRAALVM_COMMUNITY_DOWNLOAD_URL = 'https://github.com/graalvm/graalvm-ce-builds/releases';
const GRAALVM_COMMUNITY_ASSET_PREFIX = 'graalvm-community-jdk-';
const GRAALVM_COMMUNITY_VERSION_PATTERN = /^\d+(?:\.\d+)*$/;
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform; const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
const GRAALVM_MIN_VERSION = 17; const GRAALVM_MIN_VERSION = 17;
const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64']; const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'];
class GraalVMDistribution extends base_installer_1.JavaBase { class GraalVMDistribution extends base_installer_1.JavaBase {
constructor(installerOptions, distributionName = 'GraalVM') { constructor(installerOptions) {
super(distributionName, installerOptions); super('GraalVM', installerOptions);
} }
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@@ -79132,33 +79133,19 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
} }
findPackageForDownload(range) { findPackageForDownload(range) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
this.validateVersionRange(range); // Add input validation
const arch = this.getSupportedArchitecture();
if (!this.stable) {
return this.findEABuildDownloadUrl(`${range}-ea`);
}
const { platform, extension, major } = this.validateStableBuildRequest(range);
const fileUrl = this.constructFileUrl(range, major, platform, arch, extension);
const response = yield this.http.head(fileUrl);
this.handleHttpResponse(response, range);
return { url: fileUrl, version: range };
});
}
validateVersionRange(range) {
if (!range || typeof range !== 'string') { if (!range || typeof range !== 'string') {
throw new Error('Version range is required and must be a string'); throw new Error('Version range is required and must be a string');
} }
}
getSupportedArchitecture() {
const arch = this.distributionArchitecture(); const arch = this.distributionArchitecture();
if (!SUPPORTED_ARCHITECTURES.includes(arch)) { if (!SUPPORTED_ARCHITECTURES.includes(arch)) {
throw new Error(`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`); throw new Error(`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`);
} }
return arch; if (!this.stable) {
return this.findEABuildDownloadUrl(`${range}-ea`);
} }
validateStableBuildRequest(range) {
if (this.packageType !== 'jdk') { if (this.packageType !== 'jdk') {
throw new Error(`${this.distribution} provides only the \`jdk\` package type`); throw new Error('GraalVM provides only the `jdk` package type');
} }
const platform = this.getPlatform(); const platform = this.getPlatform();
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
@@ -79168,13 +79155,13 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
throw new Error(`Invalid version format: ${range}`); throw new Error(`Invalid version format: ${range}`);
} }
if (majorVersion < GRAALVM_MIN_VERSION) { if (majorVersion < GRAALVM_MIN_VERSION) {
throw new Error(`${this.distribution} is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`); throw new Error(`GraalVM is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`);
} }
return { const fileUrl = this.constructFileUrl(range, major, platform, arch, extension);
platform, const response = yield this.http.head(fileUrl);
major, this.handleHttpResponse(response, range);
extension return { url: fileUrl, version: range };
}; });
} }
constructFileUrl(range, major, platform, arch, extension) { constructFileUrl(range, major, platform, arch, extension) {
return range.includes('.') return range.includes('.')
@@ -79266,101 +79253,6 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
} }
} }
exports.GraalVMDistribution = GraalVMDistribution; exports.GraalVMDistribution = GraalVMDistribution;
class GraalVMCommunityDistribution extends GraalVMDistribution {
constructor(installerOptions) {
super(installerOptions, 'GraalVM Community');
}
get toolcacheFolderName() {
return `Java_GraalVM_Community_${this.packageType}`;
}
findPackageForDownload(range) {
return __awaiter(this, void 0, void 0, function* () {
this.validateVersionRange(range);
if (!this.stable) {
throw new Error('GraalVM Community does not provide early access builds');
}
const arch = this.getSupportedArchitecture();
const { platform, extension } = this.validateStableBuildRequest(range);
// GraalVM Community asset names embed the platform, architecture and
// archive type, e.g. `graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz`.
const assetSuffix = `_${platform}-${arch}_bin.${extension}`;
const availableVersions = yield this.getAvailableVersions(assetSuffix);
const satisfiedVersion = availableVersions
.filter(item => (0, util_1.isVersionSatisfies)(range, item.version))
.sort((a, b) => -semver_1.default.compareBuild(a.version, b.version))[0];
if (!satisfiedVersion) {
const error = this.createVersionNotFoundError(range, availableVersions.map(item => item.version), `Platform: ${platform}`);
error.message += `\nPlease check if this version is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`;
throw error;
}
return satisfiedVersion;
});
}
getAvailableVersions(assetSuffix) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const headers = (0, util_1.getGitHubHttpHeaders)();
const versions = new Map();
let releasesUrl = GRAALVM_COMMUNITY_RELEASES_URL;
for (let pageIndex = 0; releasesUrl && pageIndex < util_1.MAX_PAGINATION_PAGES; pageIndex++) {
const response = yield this.http.getJson(releasesUrl, headers);
// A successful GitHub releases listing is always a JSON array (possibly
// empty). Anything else indicates an unexpected/error payload (rate
// limiting, auth failure, etc.) that must be surfaced instead of being
// silently treated as "no releases", which would later look like a
// misleading "version not found" error.
if (!Array.isArray(response.result)) {
throw new Error(`Unexpected response while listing GraalVM Community releases from ${releasesUrl} ` +
`(HTTP status code: ${response.statusCode}). Expected a JSON array of releases. ` +
`Please check if the service is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`);
}
const releases = response.result;
if (releases.length === 0) {
break;
}
for (const release of releases) {
if (release.draft || release.prerelease) {
continue;
}
for (const asset of (_a = release.assets) !== null && _a !== void 0 ? _a : []) {
const version = this.extractAssetVersion(asset.name, assetSuffix);
if (version) {
versions.set(version, {
version,
url: asset.browser_download_url
});
}
}
}
releasesUrl = this.getNextReleasesUrl(response.headers);
}
return [...versions.values()];
});
}
// Returns the GraalVM JDK version encoded in a release asset name when it
// matches the requested platform/architecture/archive suffix, otherwise null.
extractAssetVersion(assetName, assetSuffix) {
if (!assetName.startsWith(GRAALVM_COMMUNITY_ASSET_PREFIX) ||
!assetName.endsWith(assetSuffix)) {
return null;
}
const rawVersion = assetName.slice(GRAALVM_COMMUNITY_ASSET_PREFIX.length, -assetSuffix.length);
if (!GRAALVM_COMMUNITY_VERSION_PATTERN.test(rawVersion)) {
return null;
}
return (0, util_1.convertVersionToSemver)(rawVersion);
}
getNextReleasesUrl(headers) {
const nextUrl = (0, util_1.getNextPageUrlFromLinkHeader)(headers);
if (nextUrl &&
!(0, util_1.validatePaginationUrl)(nextUrl, GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN)) {
core.warning(`Ignoring pagination link with unexpected origin: ${nextUrl}`);
return null;
}
return nextUrl;
}
}
exports.GraalVMCommunityDistribution = GraalVMCommunityDistribution;
/***/ }), /***/ }),
@@ -79852,8 +79744,14 @@ class LocalDistribution extends base_installer_1.JavaBase {
if (process.platform === 'darwin' && fs_1.default.existsSync(macOSPostfixPath)) { if (process.platform === 'darwin' && fs_1.default.existsSync(macOSPostfixPath)) {
foundJava.path = macOSPostfixPath; foundJava.path = macOSPostfixPath;
} }
core.info(`Setting Java ${foundJava.version} as default`); if (this.setDefault) {
core.info(`Setting Java ${foundJava.version} as the default`);
this.setJavaDefault(foundJava.version, foundJava.path); this.setJavaDefault(foundJava.version, foundJava.path);
}
else {
core.info(`Installing Java ${foundJava.version} (not setting as default)`);
this.setJavaEnvironment(foundJava.version, foundJava.path);
}
return foundJava; return foundJava;
}); });
} }
@@ -81011,87 +80909,6 @@ function deleteKey(keyFingerprint) {
exports.deleteKey = deleteKey; exports.deleteKey = deleteKey;
/***/ }),
/***/ 38172:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.configureMavenArgs = void 0;
const core = __importStar(__nccwpck_require__(37484));
const util_1 = __nccwpck_require__(54527);
const constants_1 = __nccwpck_require__(27242);
/**
* Configures the MAVEN_ARGS environment variable so that Maven suppresses
* artifact transfer/download progress output by default, producing cleaner
* CI logs.
*
* Behavior:
* - When `show-download-progress` is `false` (the default), `-ntp`
* (`--no-transfer-progress`) is appended to any existing MAVEN_ARGS value.
* - When `show-download-progress` is `true`, MAVEN_ARGS is left untouched so
* the user's own configuration (and Maven's default progress output) is
* preserved.
*
* The change is idempotent: if MAVEN_ARGS already disables transfer progress
* (via `-ntp` or `--no-transfer-progress`) nothing is added. Any pre-existing
* MAVEN_ARGS value is preserved.
*
* MAVEN_ARGS is honored by Maven 3.9.0+ and the Maven Wrapper; older Maven
* versions ignore it, so this is a no-op there. It has no effect on non-Maven
* builds such as Gradle or sbt.
*/
function configureMavenArgs() {
var _a;
const showDownloadProgress = (0, util_1.getBooleanInput)(constants_1.INPUT_SHOW_DOWNLOAD_PROGRESS, false);
if (showDownloadProgress) {
core.debug(`${constants_1.INPUT_SHOW_DOWNLOAD_PROGRESS} is true; leaving ${constants_1.MAVEN_ARGS_ENV} unchanged`);
return;
}
const existingArgs = ((_a = process.env[constants_1.MAVEN_ARGS_ENV]) !== null && _a !== void 0 ? _a : '').trim();
const alreadyDisabled = existingArgs
.split(/\s+/)
.some(arg => arg === constants_1.MAVEN_NO_TRANSFER_PROGRESS_FLAG ||
arg === constants_1.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG);
if (alreadyDisabled) {
core.debug(`${constants_1.MAVEN_ARGS_ENV} already disables transfer progress; leaving it unchanged`);
return;
}
const updatedArgs = existingArgs
? `${existingArgs} ${constants_1.MAVEN_NO_TRANSFER_PROGRESS_FLAG}`
: constants_1.MAVEN_NO_TRANSFER_PROGRESS_FLAG;
core.exportVariable(constants_1.MAVEN_ARGS_ENV, updatedArgs);
core.info(`Configured ${constants_1.MAVEN_ARGS_ENV} to include ${constants_1.MAVEN_NO_TRANSFER_PROGRESS_FLAG} to suppress Maven transfer progress logs. ` +
`Set '${constants_1.INPUT_SHOW_DOWNLOAD_PROGRESS}: true' to keep the download progress output.`);
}
exports.configureMavenArgs = configureMavenArgs;
/***/ }), /***/ }),
/***/ 90471: /***/ 90471:
@@ -81144,7 +80961,6 @@ const constants = __importStar(__nccwpck_require__(27242));
const cache_1 = __nccwpck_require__(97377); const cache_1 = __nccwpck_require__(97377);
const path = __importStar(__nccwpck_require__(16928)); const path = __importStar(__nccwpck_require__(16928));
const distribution_factory_1 = __nccwpck_require__(2970); const distribution_factory_1 = __nccwpck_require__(2970);
const maven_args_1 = __nccwpck_require__(38172);
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@@ -81159,6 +80975,7 @@ function run() {
const cache = core.getInput(constants.INPUT_CACHE); const cache = core.getInput(constants.INPUT_CACHE);
const cacheDependencyPath = core.getInput(constants.INPUT_CACHE_DEPENDENCY_PATH); const cacheDependencyPath = core.getInput(constants.INPUT_CACHE_DEPENDENCY_PATH);
const checkLatest = (0, util_1.getBooleanInput)(constants.INPUT_CHECK_LATEST, false); const checkLatest = (0, util_1.getBooleanInput)(constants.INPUT_CHECK_LATEST, false);
const setDefault = (0, util_1.getBooleanInput)(constants.INPUT_SET_DEFAULT, true);
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
core.startGroup('Installed distributions'); core.startGroup('Installed distributions');
if (versions.length !== toolchainIds.length) { if (versions.length !== toolchainIds.length) {
@@ -81171,6 +80988,7 @@ function run() {
architecture, architecture,
packageType, packageType,
checkLatest, checkLatest,
setDefault,
distributionName, distributionName,
jdkFile, jdkFile,
toolchainIds toolchainIds
@@ -81192,7 +81010,6 @@ function run() {
const matchersPath = path.join(__dirname, '..', '..', '.github'); const matchersPath = path.join(__dirname, '..', '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
yield auth.configureAuthentication(); yield auth.configureAuthentication();
(0, maven_args_1.configureMavenArgs)();
if (cache && (0, util_1.isCacheFeatureAvailable)()) { if (cache && (0, util_1.isCacheFeatureAvailable)()) {
yield (0, cache_1.restore)(cache, cacheDependencyPath); yield (0, cache_1.restore)(cache, cacheDependencyPath);
} }
@@ -81205,11 +81022,12 @@ function run() {
run(); run();
function installVersion(version, options, toolchainId = 0) { function installVersion(version, options, toolchainId = 0) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { distributionName, jdkFile, architecture, packageType, checkLatest, toolchainIds } = options; const { distributionName, jdkFile, architecture, packageType, checkLatest, setDefault, toolchainIds } = options;
const installerOptions = { const installerOptions = {
architecture, architecture,
packageType, packageType,
checkLatest, checkLatest,
setDefault,
version version
}; };
const distribution = (0, distribution_factory_1.getJavaDistribution)(distributionName, installerOptions, jdkFile); const distribution = (0, distribution_factory_1.getJavaDistribution)(distributionName, installerOptions, jdkFile);

View File

@@ -10,16 +10,15 @@
- [Alibaba Dragonwell](#Alibaba-Dragonwell) - [Alibaba Dragonwell](#Alibaba-Dragonwell)
- [SapMachine](#SapMachine) - [SapMachine](#SapMachine)
- [GraalVM](#GraalVM) - [GraalVM](#GraalVM)
- [GraalVM Community](#GraalVM-Community)
- [JetBrains](#JetBrains) - [JetBrains](#JetBrains)
- [Installing custom Java package type](#Installing-custom-Java-package-type) - [Installing custom Java package type](#Installing-custom-Java-package-type)
- [JavaFX Maven project](#JavaFX-Maven-project) - [JavaFX Maven project](#JavaFX-Maven-project)
- [Installing custom Java architecture](#Installing-custom-Java-architecture) - [Installing custom Java architecture](#Installing-custom-Java-architecture)
- [Installing JDK without setting as default](#Installing-JDK-without-setting-as-default)
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file) - [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
- [Testing against different Java distributions](#Testing-against-different-Java-distributions) - [Testing against different Java distributions](#Testing-against-different-Java-distributions)
- [Testing against different platforms](#Testing-against-different-platforms) - [Testing against different platforms](#Testing-against-different-platforms)
- [Publishing using Apache Maven](#Publishing-using-Apache-Maven) - [Publishing using Apache Maven](#Publishing-using-Apache-Maven)
- [Maven transfer progress (download logs)](#Maven-transfer-progress-download-logs)
- [Publishing using Gradle](#Publishing-using-Gradle) - [Publishing using Gradle](#Publishing-using-Gradle)
- [Hosted Tool Cache](#Hosted-Tool-Cache) - [Hosted Tool Cache](#Hosted-Tool-Cache)
- [Modifying Maven Toolchains](#Modifying-Maven-Toolchains) - [Modifying Maven Toolchains](#Modifying-Maven-Toolchains)
@@ -176,21 +175,6 @@ steps:
native-image --version native-image --version
``` ```
### GraalVM Community
**NOTE:** GraalVM Community is available for stable JDK 17 and later releases.
```yaml
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: 'graalvm-community'
java-version: '21'
- run: |
java --version
native-image --version
```
### JetBrains ### JetBrains
**NOTE:** JetBrains is only available for LTS versions on 11 or later (11, 17, 21, etc.). **NOTE:** JetBrains is only available for LTS versions on 11 or later (11, 17, 21, etc.).
@@ -284,12 +268,37 @@ steps:
- run: java --version - run: java --version
``` ```
## Installing JDK without setting as default
When installing multiple JDKs, the last one installed becomes the default (`JAVA_HOME`, `PATH`). Use the `set-default` option to install a JDK without overriding the default. The installed JDK is still discoverable via the `JAVA_HOME_<major>_<arch>` environment variable (e.g. `JAVA_HOME_21_X64`).
```yaml
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- uses: actions/setup-java@v5
id: setup-java-21
with:
distribution: 'temurin'
java-version: '21'
set-default: false
- run: |
echo "Default java:"
java -version
echo "Java 21 home: $JAVA_HOME_21_X64"
echo "Java 21 path from output: ${{ steps.setup-java-21.outputs.path }}"
```
In this example, `JAVA_HOME` and `java` on `PATH` point to Java 17, while Java 21 is available via `JAVA_HOME_21_X64` or the step output `path`.
> **Note:** When a single step installs multiple JDKs via a multiline `java-version`, the `set-default` value applies to all of them. With `set-default: false`, none of those JDKs become the default; each remains discoverable through its `JAVA_HOME_<major>_<arch>` variable. Regardless of `set-default`, installed JDKs are still registered in the Maven toolchains file, so they can be selected via Maven toolchains.
## Installing Java from local file ## Installing Java from local file
If your use-case requires a custom distribution or a version that is not provided by setup-java, you can download it manually and setup-java will take care of the installation and caching on the VM: If your use-case requires a custom distribution or a version that is not provided by setup-java, you can download it manually and setup-java will take care of the installation and caching on the VM:
> [!NOTE]
> This approach also lets you use builds that setup-java does not provide directly, such as **Early Access (EA)** or other unreleased JDK builds (for example, an upcoming feature release or a Loom/Valhalla preview build). Download the desired archive in a prior step and point `jdkFile` at it; setup-java will extract, install, and cache it just like a supported distribution. When targeting multiple architectures, select the correct binary per architecture in your workflow (for example, with a build matrix).
```yaml ```yaml
steps: steps:
- run: | - run: |
@@ -305,23 +314,6 @@ steps:
- run: java --version - run: java --version
``` ```
For example, to use an **Early Access** build from [jdk.java.net](https://jdk.java.net/), download the archive for your runner OS/architecture and install it via `distribution: 'jdkfile'` (example below assumes Linux x64):
```yaml
steps:
- run: |
download_url="https://download.java.net/java/early_access/jdk25/36/GPL/openjdk-25-ea+36_linux-x64_bin.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- uses: actions/setup-java@v5
with:
distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz
java-version: '25.0.0-ea.36'
architecture: x64
- run: java --version
```
If your use-case requires a custom distribution (in the example, alpine-linux is used) or a version that is not provided by setup-java and you want to always install the latest version during runtime, then you can use the following code to auto-download the latest JDK, determine the semver needed for setup-java, and setup-java will take care of the installation and caching on the VM: If your use-case requires a custom distribution (in the example, alpine-linux is used) or a version that is not provided by setup-java and you want to always install the latest version during runtime, then you can use the following code to auto-download the latest JDK, determine the semver needed for setup-java, and setup-java will take care of the installation and caching on the VM:
```yaml ```yaml
@@ -527,36 +519,6 @@ jobs:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}
``` ```
## Maven transfer progress (download logs)
By default, Maven prints a line for every artifact it downloads, which can add hundreds of noisy lines to CI logs. To keep logs clean, `setup-java` sets the [`MAVEN_ARGS`](https://maven.apache.org/configure.html#maven_args-environment-variable) environment variable to include `-ntp` (`--no-transfer-progress`) so that subsequent Maven invocations in the job suppress this transfer progress output.
This is enabled by default. Any existing `MAVEN_ARGS` value is preserved (the flag is appended, not overwritten), and the flag is not added twice if you already set it yourself.
If you want to keep the download/transfer progress in your logs, set `show-download-progress: true`:
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: '<distribution>'
java-version: '21'
show-download-progress: true # keep Maven download/transfer progress in the logs
- name: Build with Maven
run: mvn -B package --file pom.xml
```
***NOTES***:
- `MAVEN_ARGS` is honored by Maven 3.9.0+ and the Maven Wrapper (`mvnw`). Older Maven versions ignore it, so on those you can pass `--no-transfer-progress` on the command line instead.
- This setting only affects Maven. It has no effect on Gradle, sbt, or other build tools.
- `-ntp` only controls transfer/progress output; it does not change whether Maven runs in batch mode. Use `-B`/`--batch-mode` (or `<interactiveMode>false</interactiveMode>` in `settings.xml`) if you also want non-interactive runs.
## Publishing using Gradle ## Publishing using Gradle
```yaml ```yaml
jobs: jobs:

View File

@@ -6,6 +6,7 @@ export const INPUT_JAVA_PACKAGE = 'java-package';
export const INPUT_DISTRIBUTION = 'distribution'; export const INPUT_DISTRIBUTION = 'distribution';
export const INPUT_JDK_FILE = 'jdkFile'; export const INPUT_JDK_FILE = 'jdkFile';
export const INPUT_CHECK_LATEST = 'check-latest'; export const INPUT_CHECK_LATEST = 'check-latest';
export const INPUT_SET_DEFAULT = 'set-default';
export const INPUT_SERVER_ID = 'server-id'; export const INPUT_SERVER_ID = 'server-id';
export const INPUT_SERVER_USERNAME = 'server-username'; export const INPUT_SERVER_USERNAME = 'server-username';
export const INPUT_SERVER_PASSWORD = 'server-password'; export const INPUT_SERVER_PASSWORD = 'server-password';
@@ -28,10 +29,5 @@ export const MVN_SETTINGS_FILE = 'settings.xml';
export const MVN_TOOLCHAINS_FILE = 'toolchains.xml'; export const MVN_TOOLCHAINS_FILE = 'toolchains.xml';
export const INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; export const INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
export const INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; export const INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
export const INPUT_SHOW_DOWNLOAD_PROGRESS = 'show-download-progress';
export const MAVEN_ARGS_ENV = 'MAVEN_ARGS';
export const MAVEN_NO_TRANSFER_PROGRESS_FLAG = '-ntp';
export const MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = '--no-transfer-progress';
export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];

View File

@@ -20,6 +20,7 @@ export abstract class JavaBase {
protected packageType: string; protected packageType: string;
protected stable: boolean; protected stable: boolean;
protected checkLatest: boolean; protected checkLatest: boolean;
protected setDefault: boolean;
constructor( constructor(
protected distribution: string, protected distribution: string,
@@ -36,6 +37,10 @@ export abstract class JavaBase {
this.architecture = installerOptions.architecture || os.arch(); this.architecture = installerOptions.architecture || os.arch();
this.packageType = installerOptions.packageType; this.packageType = installerOptions.packageType;
this.checkLatest = installerOptions.checkLatest; this.checkLatest = installerOptions.checkLatest;
this.setDefault =
installerOptions.setDefault !== undefined
? installerOptions.setDefault
: true;
} }
protected abstract downloadTool( protected abstract downloadTool(
@@ -169,8 +174,15 @@ export abstract class JavaBase {
foundJava.path = macOSPostfixPath; foundJava.path = macOSPostfixPath;
} }
if (this.setDefault) {
core.info(`Setting Java ${foundJava.version} as the default`); core.info(`Setting Java ${foundJava.version} as the default`);
this.setJavaDefault(foundJava.version, foundJava.path); this.setJavaDefault(foundJava.version, foundJava.path);
} else {
core.info(
`Installing Java ${foundJava.version} (not setting as default)`
);
this.setJavaEnvironment(foundJava.version, foundJava.path);
}
return foundJava; return foundJava;
} }
@@ -298,9 +310,13 @@ export abstract class JavaBase {
} }
protected setJavaDefault(version: string, toolPath: string) { protected setJavaDefault(version: string, toolPath: string) {
const majorVersion = version.split('.')[0];
core.exportVariable('JAVA_HOME', toolPath); core.exportVariable('JAVA_HOME', toolPath);
core.addPath(path.join(toolPath, 'bin')); core.addPath(path.join(toolPath, 'bin'));
this.setJavaEnvironment(version, toolPath);
}
protected setJavaEnvironment(version: string, toolPath: string) {
const majorVersion = version.split('.')[0];
core.setOutput('distribution', this.distribution); core.setOutput('distribution', this.distribution);
core.setOutput('path', toolPath); core.setOutput('path', toolPath);
core.setOutput('version', version); core.setOutput('version', version);

View File

@@ -3,6 +3,7 @@ export interface JavaInstallerOptions {
architecture: string; architecture: string;
packageType: string; packageType: string;
checkLatest: boolean; checkLatest: boolean;
setDefault?: boolean;
} }
export interface JavaInstallerResults { export interface JavaInstallerResults {

View File

@@ -11,10 +11,7 @@ import {CorrettoDistribution} from './corretto/installer';
import {OracleDistribution} from './oracle/installer'; import {OracleDistribution} from './oracle/installer';
import {DragonwellDistribution} from './dragonwell/installer'; import {DragonwellDistribution} from './dragonwell/installer';
import {SapMachineDistribution} from './sapmachine/installer'; import {SapMachineDistribution} from './sapmachine/installer';
import { import {GraalVMDistribution} from './graalvm/installer';
GraalVMCommunityDistribution,
GraalVMDistribution
} from './graalvm/installer';
import {JetBrainsDistribution} from './jetbrains/installer'; import {JetBrainsDistribution} from './jetbrains/installer';
enum JavaDistribution { enum JavaDistribution {
@@ -32,7 +29,6 @@ enum JavaDistribution {
Dragonwell = 'dragonwell', Dragonwell = 'dragonwell',
SapMachine = 'sapmachine', SapMachine = 'sapmachine',
GraalVM = 'graalvm', GraalVM = 'graalvm',
GraalVMCommunity = 'graalvm-community',
JetBrains = 'jetbrains' JetBrains = 'jetbrains'
} }
@@ -78,8 +74,6 @@ export function getJavaDistribution(
return new SapMachineDistribution(installerOptions); return new SapMachineDistribution(installerOptions);
case JavaDistribution.GraalVM: case JavaDistribution.GraalVM:
return new GraalVMDistribution(installerOptions); return new GraalVMDistribution(installerOptions);
case JavaDistribution.GraalVMCommunity:
return new GraalVMCommunityDistribution(installerOptions);
case JavaDistribution.JetBrains: case JavaDistribution.JetBrains:
return new JetBrainsDistribution(installerOptions); return new JetBrainsDistribution(installerOptions);
default: default:

View File

@@ -2,7 +2,6 @@ import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import semver from 'semver';
import {JavaBase} from '../base-installer'; import {JavaBase} from '../base-installer';
import {HttpCodes} from '@actions/http-client'; import {HttpCodes} from '@actions/http-client';
import {GraalVMEAVersion} from './models'; import {GraalVMEAVersion} from './models';
@@ -12,26 +11,14 @@ import {
JavaInstallerResults JavaInstallerResults
} from '../base-models'; } from '../base-models';
import { import {
convertVersionToSemver,
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
getGitHubHttpHeaders, getGitHubHttpHeaders,
getNextPageUrlFromLinkHeader, renameWinArchive
isVersionSatisfies,
MAX_PAGINATION_PAGES,
renameWinArchive,
validatePaginationUrl
} from '../../util'; } from '../../util';
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm'; const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/'; const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
const GRAALVM_COMMUNITY_RELEASES_URL =
'https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=100';
const GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN = 'https://api.github.com';
const GRAALVM_COMMUNITY_DOWNLOAD_URL =
'https://github.com/graalvm/graalvm-ce-builds/releases';
const GRAALVM_COMMUNITY_ASSET_PREFIX = 'graalvm-community-jdk-';
const GRAALVM_COMMUNITY_VERSION_PATTERN = /^\d+(?:\.\d+)*$/;
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform; const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
const GRAALVM_MIN_VERSION = 17; const GRAALVM_MIN_VERSION = 17;
@@ -39,23 +26,9 @@ const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'] as const;
type SupportedArchitecture = (typeof SUPPORTED_ARCHITECTURES)[number]; type SupportedArchitecture = (typeof SUPPORTED_ARCHITECTURES)[number];
type OsVersions = 'linux' | 'macos' | 'windows'; type OsVersions = 'linux' | 'macos' | 'windows';
interface GraalVMCommunityAsset {
name: string;
browser_download_url: string;
}
interface GraalVMCommunityRelease {
draft: boolean;
prerelease: boolean;
assets: GraalVMCommunityAsset[];
}
export class GraalVMDistribution extends JavaBase { export class GraalVMDistribution extends JavaBase {
constructor( constructor(installerOptions: JavaInstallerOptions) {
installerOptions: JavaInstallerOptions, super('GraalVM', installerOptions);
distributionName = 'GraalVM'
) {
super(distributionName, installerOptions);
} }
protected async downloadTool( protected async downloadTool(
@@ -112,36 +85,11 @@ export class GraalVMDistribution extends JavaBase {
protected async findPackageForDownload( protected async findPackageForDownload(
range: string range: string
): Promise<JavaDownloadRelease> { ): Promise<JavaDownloadRelease> {
this.validateVersionRange(range); // Add input validation
const arch = this.getSupportedArchitecture();
if (!this.stable) {
return this.findEABuildDownloadUrl(`${range}-ea`);
}
const {platform, extension, major} = this.validateStableBuildRequest(range);
const fileUrl = this.constructFileUrl(
range,
major,
platform,
arch,
extension
);
const response = await this.http.head(fileUrl);
this.handleHttpResponse(response, range);
return {url: fileUrl, version: range};
}
protected validateVersionRange(range: string): void {
if (!range || typeof range !== 'string') { if (!range || typeof range !== 'string') {
throw new Error('Version range is required and must be a string'); throw new Error('Version range is required and must be a string');
} }
}
protected getSupportedArchitecture(): SupportedArchitecture {
const arch = this.distributionArchitecture(); const arch = this.distributionArchitecture();
if (!SUPPORTED_ARCHITECTURES.includes(arch as SupportedArchitecture)) { if (!SUPPORTED_ARCHITECTURES.includes(arch as SupportedArchitecture)) {
throw new Error( throw new Error(
@@ -149,18 +97,12 @@ export class GraalVMDistribution extends JavaBase {
); );
} }
return arch as SupportedArchitecture; if (!this.stable) {
return this.findEABuildDownloadUrl(`${range}-ea`);
} }
protected validateStableBuildRequest(range: string): {
platform: OsVersions;
extension: string;
major: string;
} {
if (this.packageType !== 'jdk') { if (this.packageType !== 'jdk') {
throw new Error( throw new Error('GraalVM provides only the `jdk` package type');
`${this.distribution} provides only the \`jdk\` package type`
);
} }
const platform = this.getPlatform(); const platform = this.getPlatform();
@@ -174,15 +116,22 @@ export class GraalVMDistribution extends JavaBase {
if (majorVersion < GRAALVM_MIN_VERSION) { if (majorVersion < GRAALVM_MIN_VERSION) {
throw new Error( throw new Error(
`${this.distribution} is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}` `GraalVM is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`
); );
} }
return { const fileUrl = this.constructFileUrl(
platform, range,
major, major,
platform,
arch,
extension extension
}; );
const response = await this.http.head(fileUrl);
this.handleHttpResponse(response, range);
return {url: fileUrl, version: range};
} }
private constructFileUrl( private constructFileUrl(
@@ -331,144 +280,3 @@ export class GraalVMDistribution extends JavaBase {
return result; return result;
} }
} }
export class GraalVMCommunityDistribution extends GraalVMDistribution {
constructor(installerOptions: JavaInstallerOptions) {
super(installerOptions, 'GraalVM Community');
}
protected get toolcacheFolderName(): string {
return `Java_GraalVM_Community_${this.packageType}`;
}
protected async findPackageForDownload(
range: string
): Promise<JavaDownloadRelease> {
this.validateVersionRange(range);
if (!this.stable) {
throw new Error('GraalVM Community does not provide early access builds');
}
const arch = this.getSupportedArchitecture();
const {platform, extension} = this.validateStableBuildRequest(range);
// GraalVM Community asset names embed the platform, architecture and
// archive type, e.g. `graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz`.
const assetSuffix = `_${platform}-${arch}_bin.${extension}`;
const availableVersions = await this.getAvailableVersions(assetSuffix);
const satisfiedVersion = availableVersions
.filter(item => isVersionSatisfies(range, item.version))
.sort((a, b) => -semver.compareBuild(a.version, b.version))[0];
if (!satisfiedVersion) {
const error = this.createVersionNotFoundError(
range,
availableVersions.map(item => item.version),
`Platform: ${platform}`
);
error.message += `\nPlease check if this version is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`;
throw error;
}
return satisfiedVersion;
}
private async getAvailableVersions(
assetSuffix: string
): Promise<JavaDownloadRelease[]> {
const headers = getGitHubHttpHeaders();
const versions = new Map<string, JavaDownloadRelease>();
let releasesUrl: string | null = GRAALVM_COMMUNITY_RELEASES_URL;
for (
let pageIndex = 0;
releasesUrl && pageIndex < MAX_PAGINATION_PAGES;
pageIndex++
) {
const response = await this.http.getJson<GraalVMCommunityRelease[]>(
releasesUrl,
headers
);
// A successful GitHub releases listing is always a JSON array (possibly
// empty). Anything else indicates an unexpected/error payload (rate
// limiting, auth failure, etc.) that must be surfaced instead of being
// silently treated as "no releases", which would later look like a
// misleading "version not found" error.
if (!Array.isArray(response.result)) {
throw new Error(
`Unexpected response while listing GraalVM Community releases from ${releasesUrl} ` +
`(HTTP status code: ${response.statusCode}). Expected a JSON array of releases. ` +
`Please check if the service is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`
);
}
const releases = response.result;
if (releases.length === 0) {
break;
}
for (const release of releases) {
if (release.draft || release.prerelease) {
continue;
}
for (const asset of release.assets ?? []) {
const version = this.extractAssetVersion(asset.name, assetSuffix);
if (version) {
versions.set(version, {
version,
url: asset.browser_download_url
});
}
}
}
releasesUrl = this.getNextReleasesUrl(response.headers);
}
return [...versions.values()];
}
// Returns the GraalVM JDK version encoded in a release asset name when it
// matches the requested platform/architecture/archive suffix, otherwise null.
private extractAssetVersion(
assetName: string,
assetSuffix: string
): string | null {
if (
!assetName.startsWith(GRAALVM_COMMUNITY_ASSET_PREFIX) ||
!assetName.endsWith(assetSuffix)
) {
return null;
}
const rawVersion = assetName.slice(
GRAALVM_COMMUNITY_ASSET_PREFIX.length,
-assetSuffix.length
);
if (!GRAALVM_COMMUNITY_VERSION_PATTERN.test(rawVersion)) {
return null;
}
return convertVersionToSemver(rawVersion);
}
private getNextReleasesUrl(
headers: Record<string, string | string[] | undefined>
): string | null {
const nextUrl = getNextPageUrlFromLinkHeader(headers);
if (
nextUrl &&
!validatePaginationUrl(nextUrl, GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN)
) {
core.warning(
`Ignoring pagination link with unexpected origin: ${nextUrl}`
);
return null;
}
return nextUrl;
}
}

View File

@@ -69,9 +69,15 @@ export class LocalDistribution extends JavaBase {
foundJava.path = macOSPostfixPath; foundJava.path = macOSPostfixPath;
} }
core.info(`Setting Java ${foundJava.version} as default`); if (this.setDefault) {
core.info(`Setting Java ${foundJava.version} as the default`);
this.setJavaDefault(foundJava.version, foundJava.path); this.setJavaDefault(foundJava.version, foundJava.path);
} else {
core.info(
`Installing Java ${foundJava.version} (not setting as default)`
);
this.setJavaEnvironment(foundJava.version, foundJava.path);
}
return foundJava; return foundJava;
} }

View File

@@ -1,69 +0,0 @@
import * as core from '@actions/core';
import {getBooleanInput} from './util';
import {
INPUT_SHOW_DOWNLOAD_PROGRESS,
MAVEN_ARGS_ENV,
MAVEN_NO_TRANSFER_PROGRESS_FLAG,
MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG
} from './constants';
/**
* Configures the MAVEN_ARGS environment variable so that Maven suppresses
* artifact transfer/download progress output by default, producing cleaner
* CI logs.
*
* Behavior:
* - When `show-download-progress` is `false` (the default), `-ntp`
* (`--no-transfer-progress`) is appended to any existing MAVEN_ARGS value.
* - When `show-download-progress` is `true`, MAVEN_ARGS is left untouched so
* the user's own configuration (and Maven's default progress output) is
* preserved.
*
* The change is idempotent: if MAVEN_ARGS already disables transfer progress
* (via `-ntp` or `--no-transfer-progress`) nothing is added. Any pre-existing
* MAVEN_ARGS value is preserved.
*
* MAVEN_ARGS is honored by Maven 3.9.0+ and the Maven Wrapper; older Maven
* versions ignore it, so this is a no-op there. It has no effect on non-Maven
* builds such as Gradle or sbt.
*/
export function configureMavenArgs(): void {
const showDownloadProgress = getBooleanInput(
INPUT_SHOW_DOWNLOAD_PROGRESS,
false
);
if (showDownloadProgress) {
core.debug(
`${INPUT_SHOW_DOWNLOAD_PROGRESS} is true; leaving ${MAVEN_ARGS_ENV} unchanged`
);
return;
}
const existingArgs = (process.env[MAVEN_ARGS_ENV] ?? '').trim();
const alreadyDisabled = existingArgs
.split(/\s+/)
.some(
arg =>
arg === MAVEN_NO_TRANSFER_PROGRESS_FLAG ||
arg === MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG
);
if (alreadyDisabled) {
core.debug(
`${MAVEN_ARGS_ENV} already disables transfer progress; leaving it unchanged`
);
return;
}
const updatedArgs = existingArgs
? `${existingArgs} ${MAVEN_NO_TRANSFER_PROGRESS_FLAG}`
: MAVEN_NO_TRANSFER_PROGRESS_FLAG;
core.exportVariable(MAVEN_ARGS_ENV, updatedArgs);
core.info(
`Configured ${MAVEN_ARGS_ENV} to include ${MAVEN_NO_TRANSFER_PROGRESS_FLAG} to suppress Maven transfer progress logs. ` +
`Set '${INPUT_SHOW_DOWNLOAD_PROGRESS}: true' to keep the download progress output.`
);
}

View File

@@ -12,7 +12,6 @@ import {restore} from './cache';
import * as path from 'path'; import * as path from 'path';
import {getJavaDistribution} from './distributions/distribution-factory'; import {getJavaDistribution} from './distributions/distribution-factory';
import {JavaInstallerOptions} from './distributions/base-models'; import {JavaInstallerOptions} from './distributions/base-models';
import {configureMavenArgs} from './maven-args';
async function run() { async function run() {
try { try {
@@ -29,6 +28,7 @@ async function run() {
constants.INPUT_CACHE_DEPENDENCY_PATH constants.INPUT_CACHE_DEPENDENCY_PATH
); );
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false); const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
const setDefault = getBooleanInput(constants.INPUT_SET_DEFAULT, true);
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
core.startGroup('Installed distributions'); core.startGroup('Installed distributions');
@@ -45,6 +45,7 @@ async function run() {
architecture, architecture,
packageType, packageType,
checkLatest, checkLatest,
setDefault,
distributionName, distributionName,
jdkFile, jdkFile,
toolchainIds toolchainIds
@@ -80,7 +81,6 @@ async function run() {
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
await auth.configureAuthentication(); await auth.configureAuthentication();
configureMavenArgs();
if (cache && isCacheFeatureAvailable()) { if (cache && isCacheFeatureAvailable()) {
await restore(cache, cacheDependencyPath); await restore(cache, cacheDependencyPath);
} }
@@ -102,6 +102,7 @@ async function installVersion(
architecture, architecture,
packageType, packageType,
checkLatest, checkLatest,
setDefault,
toolchainIds toolchainIds
} = options; } = options;
@@ -109,6 +110,7 @@ async function installVersion(
architecture, architecture,
packageType, packageType,
checkLatest, checkLatest,
setDefault,
version version
}; };
@@ -143,6 +145,7 @@ interface installerInputsOptions {
architecture: string; architecture: string;
packageType: string; packageType: string;
checkLatest: boolean; checkLatest: boolean;
setDefault: boolean;
distributionName: string; distributionName: string;
jdkFile: string; jdkFile: string;
toolchainIds: Array<string>; toolchainIds: Array<string>;