mirror of
https://github.com/actions/setup-java.git
synced 2026-07-27 22:54:32 +02:00
Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f75542ba2b | ||
|
|
c59dceb0cd | ||
|
|
8f48118d89 | ||
|
|
c79143eaae | ||
|
|
77c695c0d0 | ||
|
|
7b26641a55 | ||
|
|
e08df439e0 | ||
|
|
cd3b6000e4 | ||
|
|
c3d7ccbf81 | ||
|
|
46f6294045 | ||
|
|
e40a8e0642 | ||
|
|
6e2e32e729 | ||
|
|
38fa86f9e4 | ||
|
|
ecd5f809c2 | ||
|
|
4a24efdcc9 | ||
|
|
cc8cdedf67 | ||
|
|
4b0728bd0d | ||
|
|
7d485884af | ||
|
|
c3568cc9d9 | ||
|
|
81c13a41f9 | ||
|
|
3c85b14378 | ||
|
|
80c368b720 |
@@ -1,102 +0,0 @@
|
|||||||
name: Validate cache with cache-dependency-path option
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- releases/*
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
gradle1-save:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Run setup-java with the cache for gradle
|
|
||||||
uses: ./
|
|
||||||
id: setup-java
|
|
||||||
with:
|
|
||||||
distribution: 'adopt'
|
|
||||||
java-version: '17'
|
|
||||||
cache: gradle
|
|
||||||
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
|
|
||||||
- name: Create files to cache
|
|
||||||
# Need to avoid using Gradle daemon to stabilize the save process on Windows
|
|
||||||
# https://github.com/actions/cache/issues/454#issuecomment-840493935
|
|
||||||
run: |
|
|
||||||
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
|
||||||
if [ ! -d ~/.gradle/caches ]; then
|
|
||||||
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
gradle1-restore:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
needs: gradle1-save
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Run setup-java with the cache for gradle
|
|
||||||
uses: ./
|
|
||||||
id: setup-java
|
|
||||||
with:
|
|
||||||
distribution: 'adopt'
|
|
||||||
java-version: '11'
|
|
||||||
cache: gradle
|
|
||||||
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
|
|
||||||
- name: Confirm that ~/.gradle/caches directory has been made
|
|
||||||
run: |
|
|
||||||
if [ ! -d ~/.gradle/caches ]; then
|
|
||||||
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ls ~/.gradle/caches/
|
|
||||||
gradle2-restore:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
needs: gradle1-save
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Run setup-java with the cache for gradle
|
|
||||||
uses: ./
|
|
||||||
id: setup-java
|
|
||||||
with:
|
|
||||||
distribution: 'adopt'
|
|
||||||
java-version: '11'
|
|
||||||
cache: gradle
|
|
||||||
cache-dependency-path: __tests__/cache/gradle2/*.gradle*
|
|
||||||
- name: Confirm that ~/.gradle/caches directory has not been made
|
|
||||||
run: |
|
|
||||||
if [ -d ~/.gradle/caches ]; then
|
|
||||||
echo "::error::The ~/.gradle/caches directory exists unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
+255
-54
@@ -42,10 +42,7 @@ jobs:
|
|||||||
# https://github.com/actions/cache/issues/454#issuecomment-840493935
|
# https://github.com/actions/cache/issues/454#issuecomment-840493935
|
||||||
run: |
|
run: |
|
||||||
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
||||||
if [ ! -d ~/.gradle/caches ]; then
|
bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
||||||
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
gradle-restore:
|
gradle-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -66,12 +63,7 @@ jobs:
|
|||||||
java-version: '11'
|
java-version: '11'
|
||||||
cache: gradle
|
cache: gradle
|
||||||
- name: Confirm that ~/.gradle/caches directory has been made
|
- name: Confirm that ~/.gradle/caches directory has been made
|
||||||
run: |
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
||||||
if [ ! -d ~/.gradle/caches ]; then
|
|
||||||
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ls ~/.gradle/caches/
|
|
||||||
maven-save:
|
maven-save:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -93,10 +85,7 @@ jobs:
|
|||||||
- name: Create files to cache
|
- name: Create files to cache
|
||||||
run: |
|
run: |
|
||||||
mvn verify -f __tests__/cache/maven/pom.xml
|
mvn verify -f __tests__/cache/maven/pom.xml
|
||||||
if [ ! -d ~/.m2/repository ]; then
|
bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
||||||
echo "::error::The ~/.m2/repository directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
maven-restore:
|
maven-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -117,12 +106,7 @@ jobs:
|
|||||||
java-version: '11'
|
java-version: '11'
|
||||||
cache: maven
|
cache: maven
|
||||||
- name: Confirm that ~/.m2/repository directory has been made
|
- name: Confirm that ~/.m2/repository directory has been made
|
||||||
run: |
|
run: bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
||||||
if [ ! -d ~/.m2/repository ]; then
|
|
||||||
echo "::error::The ~/.m2/repository directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ls ~/.m2/repository
|
|
||||||
sbt-save:
|
sbt-save:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
defaults:
|
defaults:
|
||||||
@@ -155,25 +139,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Check files to cache on macos-latest
|
- name: Check files to cache on macos-latest
|
||||||
if: matrix.os == 'macos-15-intel'
|
if: matrix.os == 'macos-15-intel'
|
||||||
run: |
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
||||||
if [ ! -d ~/Library/Caches/Coursier ]; then
|
|
||||||
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- name: Check files to cache on windows-latest
|
- name: Check files to cache on windows-latest
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
||||||
if [ ! -d ~/AppData/Local/Coursier/Cache ]; then
|
|
||||||
echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- name: Check files to cache on ubuntu-latest
|
- name: Check files to cache on ubuntu-latest
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
run: |
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||||
if [ ! -d ~/.cache/coursier ]; then
|
|
||||||
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sbt-restore:
|
sbt-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
defaults:
|
defaults:
|
||||||
@@ -200,25 +172,254 @@ jobs:
|
|||||||
|
|
||||||
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
||||||
if: matrix.os == 'macos-15-intel'
|
if: matrix.os == 'macos-15-intel'
|
||||||
run: |
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
||||||
if [ ! -d ~/Library/Caches/Coursier ]; then
|
|
||||||
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ls ~/Library/Caches/Coursier
|
|
||||||
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
|
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
||||||
if [ ! -d ~/AppData/Local/Coursier/Cache ]; then
|
|
||||||
echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ls ~/AppData/Local/Coursier/Cache
|
|
||||||
- name: Confirm that ~/.cache/coursier directory has been made
|
- name: Confirm that ~/.cache/coursier directory has been made
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||||
|
gradle1-save:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for gradle
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '17'
|
||||||
|
cache: gradle
|
||||||
|
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
|
||||||
|
- name: Create files to cache
|
||||||
|
# Need to avoid using Gradle daemon to stabilize the save process on Windows
|
||||||
|
# https://github.com/actions/cache/issues/454#issuecomment-840493935
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d ~/.cache/coursier ]; then
|
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
||||||
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
|
bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
||||||
exit 1
|
gradle1-restore:
|
||||||
fi
|
runs-on: ${{ matrix.os }}
|
||||||
ls ~/.cache/coursier
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
|
needs: gradle1-save
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for gradle
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
|
cache: gradle
|
||||||
|
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
|
||||||
|
- name: Confirm that ~/.gradle/caches directory has been made
|
||||||
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
||||||
|
gradle2-restore:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
|
needs: gradle1-save
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for gradle
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
|
cache: gradle
|
||||||
|
cache-dependency-path: __tests__/cache/gradle2/*.gradle*
|
||||||
|
- name: Confirm that ~/.gradle/caches directory has not been made
|
||||||
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches" absent
|
||||||
|
maven1-save:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for maven
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
|
cache: maven
|
||||||
|
cache-dependency-path: __tests__/cache/maven/pom.xml
|
||||||
|
- name: Create files to cache
|
||||||
|
run: |
|
||||||
|
mvn verify -f __tests__/cache/maven/pom.xml
|
||||||
|
bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
||||||
|
maven1-restore:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
|
needs: maven1-save
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for maven
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
|
cache: maven
|
||||||
|
cache-dependency-path: __tests__/cache/maven/pom.xml
|
||||||
|
- name: Confirm that ~/.m2/repository directory has been made
|
||||||
|
run: bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
||||||
|
maven2-restore:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
|
needs: maven1-save
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for maven
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
|
cache: maven
|
||||||
|
cache-dependency-path: __tests__/cache/maven2/pom.xml
|
||||||
|
- name: Confirm that ~/.m2/repository directory has not been made
|
||||||
|
run: bash __tests__/check-dir.sh "$HOME/.m2/repository" absent
|
||||||
|
sbt1-save:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
working-directory: __tests__/cache/sbt
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for sbt
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
|
cache: sbt
|
||||||
|
cache-dependency-path: __tests__/cache/sbt/*.sbt
|
||||||
|
- name: Setup SBT
|
||||||
|
if: matrix.os == 'macos-15-intel'
|
||||||
|
run: |
|
||||||
|
echo ""Installing SBT...""
|
||||||
|
brew install sbt
|
||||||
|
- name: Create files to cache
|
||||||
|
run: sbt update
|
||||||
|
|
||||||
|
- name: Check files to cache on macos-latest
|
||||||
|
if: matrix.os == 'macos-15-intel'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
||||||
|
- name: Check files to cache on windows-latest
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
||||||
|
- name: Check files to cache on ubuntu-latest
|
||||||
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||||
|
sbt1-restore:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
working-directory: __tests__/cache/sbt
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||||
|
needs: sbt1-save
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for sbt
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
|
cache: sbt
|
||||||
|
cache-dependency-path: __tests__/cache/sbt/*.sbt
|
||||||
|
|
||||||
|
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
||||||
|
if: matrix.os == 'macos-15-intel'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
||||||
|
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
||||||
|
- name: Confirm that ~/.cache/coursier directory has been made
|
||||||
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||||
|
sbt2-restore:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
working-directory: __tests__/cache/sbt2
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||||
|
needs: sbt1-save
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run setup-java with the cache for sbt
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: 'adopt'
|
||||||
|
java-version: '11'
|
||||||
|
cache: sbt
|
||||||
|
cache-dependency-path: __tests__/cache/sbt2/*.sbt
|
||||||
|
|
||||||
|
- name: Confirm that ~/Library/Caches/Coursier directory has not been made
|
||||||
|
if: matrix.os == 'macos-15-intel'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier" absent
|
||||||
|
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has not been made
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache" absent
|
||||||
|
- name: Confirm that ~/.cache/coursier directory has not been made
|
||||||
|
if: matrix.os == 'ubuntu-22.04'
|
||||||
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier" absent
|
||||||
|
|||||||
@@ -38,21 +38,33 @@ jobs:
|
|||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
server-id: maven
|
server-id: maven
|
||||||
server-username: MAVEN_USERNAME
|
server-username-env-var: MAVEN_USERNAME
|
||||||
server-password: MAVEN_CENTRAL_TOKEN
|
server-password-env-var: MAVEN_CENTRAL_TOKEN
|
||||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
|
||||||
- name: Validate settings.xml
|
- name: Validate settings.xml
|
||||||
run: |
|
run: |
|
||||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||||
Get-Content $xmlPath | ForEach-Object { Write-Host $_ }
|
Get-Content $xmlPath | ForEach-Object { Write-Host $_ }
|
||||||
|
|
||||||
[xml]$xml = Get-Content $xmlPath
|
$content = [System.IO.File]::ReadAllText($xmlPath)
|
||||||
$servers = $xml.settings.servers.server
|
$expected = @(
|
||||||
if (($servers[0].id -ne 'maven') -or ($servers[0].username -ne '${env.MAVEN_USERNAME}') -or ($servers[0].password -ne '${env.MAVEN_CENTRAL_TOKEN}')) {
|
'<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"'
|
||||||
throw "Generated XML file is incorrect"
|
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
|
||||||
}
|
' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">'
|
||||||
|
' <interactiveMode>false</interactiveMode>'
|
||||||
|
' <servers>'
|
||||||
|
' <server>'
|
||||||
|
' <id>maven</id>'
|
||||||
|
' <username>${env.MAVEN_USERNAME}</username>'
|
||||||
|
' <password>${env.MAVEN_CENTRAL_TOKEN}</password>'
|
||||||
|
' </server>'
|
||||||
|
' </servers>'
|
||||||
|
'</settings>'
|
||||||
|
) -join "`n"
|
||||||
|
|
||||||
if (($servers[1].id -ne 'gpg.passphrase') -or ($servers[1].passphrase -ne '${env.MAVEN_GPG_PASSPHRASE}')) {
|
if ($content -ne $expected) {
|
||||||
|
Write-Host "Expected settings.xml:"
|
||||||
|
$expected -split "`n" | ForEach-Object { Write-Host $_ }
|
||||||
throw "Generated XML file is incorrect"
|
throw "Generated XML file is incorrect"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,9 +93,9 @@ jobs:
|
|||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
server-id: maven
|
server-id: maven
|
||||||
server-username: MAVEN_USERNAME
|
server-username-env-var: MAVEN_USERNAME
|
||||||
server-password: MAVEN_CENTRAL_TOKEN
|
server-password-env-var: MAVEN_CENTRAL_TOKEN
|
||||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
|
||||||
- name: Validate settings.xml is overwritten
|
- name: Validate settings.xml is overwritten
|
||||||
run: |
|
run: |
|
||||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||||
@@ -119,10 +131,10 @@ jobs:
|
|||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
server-id: maven
|
server-id: maven
|
||||||
server-username: MAVEN_USERNAME
|
server-username-env-var: MAVEN_USERNAME
|
||||||
server-password: MAVEN_CENTRAL_TOKEN
|
server-password-env-var: MAVEN_CENTRAL_TOKEN
|
||||||
overwrite-settings: false
|
overwrite-settings: false
|
||||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
|
||||||
- name: Validate that settings.xml is not overwritten
|
- name: Validate that settings.xml is not overwritten
|
||||||
run: |
|
run: |
|
||||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||||
@@ -152,9 +164,9 @@ jobs:
|
|||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
server-id: maven
|
server-id: maven
|
||||||
server-username: MAVEN_USERNAME
|
server-username-env-var: MAVEN_USERNAME
|
||||||
server-password: MAVEN_CENTRAL_TOKEN
|
server-password-env-var: MAVEN_CENTRAL_TOKEN
|
||||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
|
||||||
settings-path: ${{ runner.temp }}
|
settings-path: ${{ runner.temp }}
|
||||||
- name: Validate settings.xml location
|
- name: Validate settings.xml location
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ jobs:
|
|||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: '24-ea'
|
version: '24-ea'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- &checkout_step
|
||||||
|
name: Checkout
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
@@ -127,10 +128,7 @@ jobs:
|
|||||||
distribution: ['temurin', 'sapmachine']
|
distribution: ['temurin', 'sapmachine']
|
||||||
version: ['21', '17']
|
version: ['21', '17']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
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
|
||||||
@@ -153,7 +151,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: &default_os [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution: ['temurin', 'zulu', 'liberica']
|
distribution: ['temurin', 'zulu', 'liberica']
|
||||||
version:
|
version:
|
||||||
- '11.0'
|
- '11.0'
|
||||||
@@ -182,10 +180,7 @@ jobs:
|
|||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: '17.0.7'
|
version: '17.0.7'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@@ -207,7 +202,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: *default_os
|
||||||
distribution:
|
distribution:
|
||||||
[
|
[
|
||||||
'temurin',
|
'temurin',
|
||||||
@@ -221,10 +216,7 @@ jobs:
|
|||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@@ -247,7 +239,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: *default_os
|
||||||
distribution:
|
distribution:
|
||||||
[
|
[
|
||||||
'temurin',
|
'temurin',
|
||||||
@@ -261,10 +253,7 @@ jobs:
|
|||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@@ -294,26 +283,37 @@ jobs:
|
|||||||
run: bash __tests__/verify-java.sh "17" "$JAVA_PATH"
|
run: bash __tests__/verify-java.sh "17" "$JAVA_PATH"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-java-ea-versions-zulu:
|
setup-java-ea-versions:
|
||||||
name: zulu ${{ matrix.version }} (jdk-${{ contains(matrix.os, 'macos') && !contains(matrix.os, 'intel') && 'arm64' || 'x64' }}) - ${{ matrix.os }}
|
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-${{ contains(matrix.os, 'macos') && !contains(matrix.os, 'intel') && 'arm64' || 'x64' }}) - ${{ matrix.os }}
|
||||||
needs: setup-java-major-minor-versions
|
needs: setup-java-major-minor-versions
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
include:
|
||||||
version: ['17-ea', '15.0.0-ea.14']
|
- {os: macos-15-intel, version: '17-ea', distribution: zulu}
|
||||||
|
- {os: windows-latest, version: '17-ea', distribution: zulu}
|
||||||
|
- {os: ubuntu-latest, version: '17-ea', distribution: zulu}
|
||||||
|
- {os: macos-15-intel, version: '15.0.0-ea.14', distribution: zulu}
|
||||||
|
- {os: windows-latest, version: '15.0.0-ea.14', distribution: zulu}
|
||||||
|
- {os: ubuntu-latest, version: '15.0.0-ea.14', distribution: zulu}
|
||||||
|
- {os: macos-latest, version: '17-ea', distribution: temurin}
|
||||||
|
- {os: windows-latest, version: '17-ea', distribution: temurin}
|
||||||
|
- {os: ubuntu-latest, version: '17-ea', distribution: temurin}
|
||||||
|
- {os: macos-latest, version: '17-ea', distribution: sapmachine}
|
||||||
|
- {os: windows-latest, version: '17-ea', distribution: sapmachine}
|
||||||
|
- {os: ubuntu-latest, version: '17-ea', distribution: sapmachine}
|
||||||
|
- {os: macos-latest, version: '21-ea', distribution: sapmachine}
|
||||||
|
- {os: windows-latest, version: '21-ea', distribution: sapmachine}
|
||||||
|
- {os: ubuntu-latest, version: '21-ea', distribution: sapmachine}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.version }}
|
java-version: ${{ matrix.version }}
|
||||||
distribution: zulu
|
distribution: ${{ matrix.distribution }}
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
env:
|
env:
|
||||||
JAVA_VERSION: ${{ matrix.version }}
|
JAVA_VERSION: ${{ matrix.version }}
|
||||||
@@ -321,53 +321,24 @@ jobs:
|
|||||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-java-ea-versions-temurin:
|
setup-java-signature-verification:
|
||||||
name: temurin ${{ matrix.version }} (jdk-${{ contains(matrix.os, 'macos') && !contains(matrix.os, 'intel') && 'arm64' || 'x64' }}) - ${{ matrix.os }}
|
name: ${{ matrix.distribution }} ${{ matrix.version }} signature verification - ${{ matrix.os }}
|
||||||
needs: setup-java-major-minor-versions
|
needs: setup-java-major-minor-versions
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: *default_os
|
||||||
version: ['17-ea']
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java
|
|
||||||
uses: ./
|
|
||||||
id: setup-java
|
|
||||||
with:
|
|
||||||
java-version: ${{ matrix.version }}
|
|
||||||
distribution: temurin
|
|
||||||
- name: Verify Java
|
|
||||||
env:
|
|
||||||
JAVA_VERSION: ${{ matrix.version }}
|
|
||||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
|
||||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
setup-java-temurin-signature-verification:
|
|
||||||
name: temurin ${{ matrix.version }} signature verification - ${{ matrix.os }}
|
|
||||||
needs: setup-java-major-minor-versions
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
version: ['21', '17']
|
version: ['21', '17']
|
||||||
|
distribution: [temurin, microsoft]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java with signature verification
|
- name: setup-java with signature verification
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.version }}
|
java-version: ${{ matrix.version }}
|
||||||
distribution: temurin
|
distribution: ${{ matrix.distribution }}
|
||||||
verify-signature: true
|
verify-signature: true
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
env:
|
env:
|
||||||
@@ -376,61 +347,6 @@ jobs:
|
|||||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-java-microsoft-signature-verification:
|
|
||||||
name: microsoft ${{ matrix.version }} signature verification - ${{ matrix.os }}
|
|
||||||
needs: setup-java-major-minor-versions
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
version: ['21', '17']
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java with signature verification
|
|
||||||
uses: ./
|
|
||||||
id: setup-java
|
|
||||||
with:
|
|
||||||
java-version: ${{ matrix.version }}
|
|
||||||
distribution: microsoft
|
|
||||||
verify-signature: true
|
|
||||||
- name: Verify Java
|
|
||||||
env:
|
|
||||||
JAVA_VERSION: ${{ matrix.version }}
|
|
||||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
|
||||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
setup-java-ea-versions-sapmachine:
|
|
||||||
name: sapmachine ${{ matrix.version }} (jdk-${{ contains(matrix.os, 'macos') && !contains(matrix.os, 'intel') && 'arm64' || 'x64' }}) - ${{ matrix.os }}
|
|
||||||
needs: setup-java-major-minor-versions
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
version: ['17-ea', '21-ea']
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java
|
|
||||||
uses: ./
|
|
||||||
id: setup-java
|
|
||||||
with:
|
|
||||||
java-version: ${{ matrix.version }}
|
|
||||||
distribution: sapmachine
|
|
||||||
- name: Verify Java
|
|
||||||
env:
|
|
||||||
JAVA_VERSION: ${{ matrix.version }}
|
|
||||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
|
||||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
setup-java-custom-package-type:
|
setup-java-custom-package-type:
|
||||||
name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }}
|
name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }}
|
||||||
needs: setup-java-major-minor-versions
|
needs: setup-java-major-minor-versions
|
||||||
@@ -510,10 +426,7 @@ jobs:
|
|||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@@ -543,10 +456,7 @@ jobs:
|
|||||||
distribution: ['liberica', 'zulu', 'corretto']
|
distribution: ['liberica', 'zulu', 'corretto']
|
||||||
version: ['11']
|
version: ['11']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@@ -567,14 +477,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: *default_os
|
||||||
distribution: ['temurin', 'microsoft', 'corretto']
|
distribution: ['temurin', 'microsoft', 'corretto']
|
||||||
java-version-file: ['.java-version', '.tool-versions']
|
java-version-file: ['.java-version', '.tool-versions']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
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
|
||||||
@@ -600,14 +507,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: *default_os
|
||||||
distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto']
|
distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto']
|
||||||
java-version-file: ['.java-version', '.tool-versions']
|
java-version-file: ['.java-version', '.tool-versions']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
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
|
||||||
@@ -632,14 +536,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: *default_os
|
||||||
distribution: ['adopt', 'adopt-openj9', 'zulu']
|
distribution: ['adopt', 'adopt-openj9', 'zulu']
|
||||||
java-version-file: ['.java-version', '.tool-versions']
|
java-version-file: ['.java-version', '.tool-versions']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
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
|
||||||
@@ -664,14 +565,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: *default_os
|
||||||
distribution: ['adopt', 'zulu', 'liberica']
|
distribution: ['adopt', 'zulu', 'liberica']
|
||||||
java-version-file: ['.java-version', '.tool-versions', '.sdkmanrc']
|
java-version-file: ['.java-version', '.tool-versions', '.sdkmanrc']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
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
|
||||||
@@ -700,10 +598,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: *default_os
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- *checkout_step
|
||||||
uses: actions/checkout@v7
|
|
||||||
- name: Setup Java 17 as default
|
- name: Setup Java 17 as default
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java-17
|
id: setup-java-17
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v7
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
|
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/cache"
|
name: "@actions/cache"
|
||||||
version: 6.1.0
|
version: 6.2.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions cache lib
|
summary: Actions cache lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
|
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
|
||||||
|
|||||||
@@ -20,7 +20,18 @@ This action allows you to work with Java and Scala projects.
|
|||||||
|
|
||||||
## What's new in V6
|
## What's new in V6
|
||||||
|
|
||||||
- **Migrated to ESM** to enable support for the latest `@actions/*` package versions. This is an internal implementation change only. No changes are required to your workflow configuration, and the action's behavior is unchanged. Existing workflows continue to work as before.
|
> [!NOTE]
|
||||||
|
> V6 is still in development (`main` branch) and is not yet recommended for production workflows.
|
||||||
|
|
||||||
|
- **Migrated to ESM** to enable support for the latest `@actions/*` package versions. This is an internal implementation change.
|
||||||
|
|
||||||
|
## Breaking changes in V6
|
||||||
|
|
||||||
|
- **Renamed inputs that accept environment-variable names** to make it clear that their values are not credentials. Replace `server-username`, `server-password`, and `gpg-passphrase` with `server-username-env-var`, `server-password-env-var`, and `gpg-passphrase-env-var`, respectively. The old names remain as deprecated aliases and emit a warning when used.
|
||||||
|
|
||||||
|
- **The GPG passphrase is now passed to the Maven GPG Plugin through an environment variable (`gpg.passphraseEnvName`) instead of the deprecated `gpg.passphrase` server in `settings.xml`.** Set the environment variable name with `gpg-passphrase-env-var`, which defaults to `GPG_PASSPHRASE`. This requires `maven-gpg-plugin` **3.2.0 or newer**; older versions do not honor `gpg.passphraseEnvName` and, because the `gpg.passphrase` server is no longer written, will not pick up the passphrase. Upgrade the plugin to 3.2.0+.
|
||||||
|
|
||||||
|
See [GPG](docs/advanced-usage.md#gpg) for details.
|
||||||
|
|
||||||
## Breaking changes in V5
|
## Breaking changes in V5
|
||||||
|
|
||||||
@@ -47,10 +58,14 @@ For more details, see the full release notes on the [releases page](https://git
|
|||||||
|
|
||||||
- `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.
|
- `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.
|
||||||
|
|
||||||
|
- `problem-matcher`: Set to `false` to disable Java problem matcher annotations (compiler diagnostics and uncaught exceptions). Default value: `true`. See [Java problem matcher](docs/advanced-usage.md#java-problem-matcher-compiler-annotations) for details and annotation limits.
|
||||||
|
|
||||||
- `verify-signature`: Verifies downloaded Java package signatures when supported by the selected distribution. Currently supported for `temurin` and `microsoft`. If set to `true` for unsupported distributions, the action fails.
|
- `verify-signature`: Verifies downloaded Java package signatures when supported by the selected distribution. Currently supported for `temurin` and `microsoft`. If set to `true` for unsupported distributions, the action fails.
|
||||||
|
|
||||||
- `verify-signature-public-key`: ASCII-armored GPG public key used to verify the downloaded package signature. Overrides the default bundled key for the selected distribution.
|
- `verify-signature-public-key`: ASCII-armored GPG public key used to verify the downloaded package signature. Overrides the default bundled key for the selected distribution.
|
||||||
|
|
||||||
|
- `token`: The token used to authenticate when fetching version manifests hosted on GitHub.com. Defaults to `${{ github.token }}` when running on GitHub.com; defaults to an empty string on GitHub Enterprise Server. On GHES, provide a GitHub.com personal access token if manifest requests are rate-limited. See [Using Microsoft distribution on GHES](docs/advanced-usage.md#using-microsoft-distribution-on-ghes) 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.
|
||||||
@@ -62,42 +77,44 @@ For more details, see the full release notes on the [releases page](https://git
|
|||||||
|
|
||||||
- `server-id`: ID of the distributionManagement repository in the pom.xml file. Default is `github`.
|
- `server-id`: ID of the distributionManagement repository in the pom.xml file. Default is `github`.
|
||||||
|
|
||||||
- `server-username`: Environment variable name for the username for authentication to the Apache Maven repository. Default is GITHUB_ACTOR.
|
- `server-username-env-var`: Environment variable name for the username for authentication to the Apache Maven repository. Default is GITHUB\_ACTOR.
|
||||||
|
|
||||||
- `server-password`: Environment variable name for password or token for authentication to the Apache Maven repository. Default is GITHUB_TOKEN.
|
- `server-password-env-var`: Environment variable name for password or token for authentication to the Apache Maven repository. Default is GITHUB\_TOKEN.
|
||||||
|
|
||||||
- `settings-path`: Maven related setting to point to the directory where the settings.xml file will be written. Default is ~/.m2.
|
- `settings-path`: Maven related setting to point to the directory where the settings.xml file will be written. Default is \~/.m2.
|
||||||
|
|
||||||
- `gpg-private-key`: GPG private key to import. Default is empty string.
|
- `gpg-private-key`: GPG private key to import. Default is empty string.
|
||||||
|
|
||||||
- `gpg-passphrase`: Environment variable name for the GPG private key passphrase. Default is GPG_PASSPHRASE.
|
- `gpg-passphrase-env-var`: Environment variable name for the GPG private key passphrase. Default is GPG\_PASSPHRASE.
|
||||||
|
|
||||||
- `mvn-toolchain-id`: Name of Maven Toolchain ID if the default name of `${distribution}_${java-version}` is not wanted.
|
- `mvn-toolchain-id`: Name of Maven Toolchain ID if the default name of `${distribution}_${java-version}` is not wanted.
|
||||||
|
|
||||||
- `mvn-toolchain-vendor`: Name of Maven Toolchain Vendor if the default name of `${distribution}` is not wanted.
|
- `mvn-toolchain-vendor`: Name of Maven Toolchain Vendor if the default name of `${distribution}` is not wanted.
|
||||||
|
|
||||||
|
- `show-download-progress`: Set to `true` to keep Maven artifact download and transfer progress in build logs. Default value: `false`. By default, the action adds `-ntp` (`--no-transfer-progress`) to `MAVEN_ARGS`. This input has no effect on non-Maven builds. See [Maven transfer progress](docs/advanced-usage.md#maven-transfer-progress-download-logs) for more details.
|
||||||
|
|
||||||
### Basic Configuration
|
### Basic Configuration
|
||||||
|
|
||||||
#### Eclipse Temurin
|
#### Eclipse Temurin
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
- run: java --version
|
- run: java --version
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Azul Zulu OpenJDK
|
#### Azul Zulu OpenJDK
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu' # See 'Supported distributions' for available options
|
distribution: 'zulu' # See 'Supported distributions' for available options
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
- run: java --version
|
- run: java --version
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Supported version syntax
|
#### Supported version syntax
|
||||||
@@ -163,24 +180,26 @@ The workflow output `cache-primary-key` exposes the primary cache key computed b
|
|||||||
|
|
||||||
The cache input is optional, and caching is turned off by default.
|
The cache input is optional, and caching is turned off by default.
|
||||||
|
|
||||||
**Maven Wrapper:** when `cache: 'maven'` is enabled, the action also caches and restores the Maven Wrapper distribution downloaded to `~/.m2/wrapper/dists` (in addition to the local repository), so wrapper-based (`./mvnw`) builds don't re-download the wrapper on every run. This is keyed on `**/.mvn/wrapper/maven-wrapper.properties` as shown above.
|
**Maven Wrapper:** when `cache: 'maven'` is enabled, the action also caches and restores the Maven Wrapper distribution downloaded to `~/.m2/wrapper/dists` (in addition to the local repository), so wrapper-based (`./mvnw`) builds don't re-download the Maven distribution. The wrapper distribution is stored in a **separate** cache entry keyed only on `**/.mvn/wrapper/maven-wrapper.properties`, so it stays cached across the frequent `pom.xml` changes that rotate the main dependency cache key.
|
||||||
|
|
||||||
#### Caching gradle dependencies
|
#### Caching gradle dependencies
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
cache-dependency-path: | # optional
|
cache-dependency-path: | # optional
|
||||||
sub-project/*.gradle*
|
sub-project/*.gradle*
|
||||||
sub-project/**/gradle-wrapper.properties
|
sub-project/**/gradle-wrapper.properties
|
||||||
- run: ./gradlew build --no-daemon
|
- run: ./gradlew build --no-daemon
|
||||||
```
|
```
|
||||||
Using the `cache: gradle` provides a simple and effective way to cache Gradle dependencies with minimal configuration.
|
Using the `cache: gradle` provides a simple and effective way to cache Gradle dependencies with minimal configuration.
|
||||||
|
|
||||||
|
**Gradle Wrapper:** when `cache: 'gradle'` is enabled, the action also caches and restores the Gradle Wrapper distribution downloaded to `~/.gradle/wrapper` (in addition to the Gradle caches), so wrapper-based (`./gradlew`) builds don't re-download the Gradle distribution. The wrapper distribution is stored in a **separate** cache entry keyed only on `**/gradle-wrapper.properties`, so it stays cached across the frequent `*.gradle*` changes that rotate the main dependency cache key.
|
||||||
|
|
||||||
For projects that require more advanced `Gradle` caching features, such as caching build outputs, support for Gradle configuration cache, encrypted cache storage, fine-grained cache control (including options to enable or disable the cache, set it to read-only or write-only, perform automated cleanup, and define custom cache rules), or optimized performance for complex CI workflows, consider using [`gradle/actions/setup-gradle`](https://github.com/gradle/actions/tree/main/setup-gradle).
|
For projects that require more advanced `Gradle` caching features, such as caching build outputs, support for Gradle configuration cache, encrypted cache storage, fine-grained cache control (including options to enable or disable the cache, set it to read-only or write-only, perform automated cleanup, and define custom cache rules), or optimized performance for complex CI workflows, consider using [`gradle/actions/setup-gradle`](https://github.com/gradle/actions/tree/main/setup-gradle).
|
||||||
|
|
||||||
For setup details and a comprehensive overview of all available features, visit the [setup-gradle documentation](https://github.com/gradle/actions/blob/main/docs/setup-gradle.md).
|
For setup details and a comprehensive overview of all available features, visit the [setup-gradle documentation](https://github.com/gradle/actions/blob/main/docs/setup-gradle.md).
|
||||||
@@ -188,15 +207,15 @@ For setup details and a comprehensive overview of all available features, visit
|
|||||||
#### Caching maven dependencies
|
#### Caching maven dependencies
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
cache: 'maven'
|
cache: 'maven'
|
||||||
cache-dependency-path: 'sub-project/pom.xml' # optional
|
cache-dependency-path: 'sub-project/pom.xml' # optional
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn -B package --file pom.xml
|
run: mvn package --file pom.xml
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
@@ -209,17 +228,17 @@ steps:
|
|||||||
#### Caching sbt dependencies
|
#### Caching sbt dependencies
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
cache: 'sbt'
|
cache: 'sbt'
|
||||||
cache-dependency-path: | # optional
|
cache-dependency-path: | # optional
|
||||||
sub-project/build.sbt
|
sub-project/build.sbt
|
||||||
sub-project/project/build.properties
|
sub-project/project/build.properties
|
||||||
- name: Build with SBT
|
- name: Build with SBT
|
||||||
run: sbt package
|
run: sbt package
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Cache segment restore timeout
|
#### Cache segment restore timeout
|
||||||
@@ -229,13 +248,13 @@ Usually, cache gets downloaded in multiple segments of fixed sizes. Sometimes, a
|
|||||||
env:
|
env:
|
||||||
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
|
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
- run: ./gradlew build --no-daemon
|
- run: ./gradlew build --no-daemon
|
||||||
```
|
```
|
||||||
|
|
||||||
### Check latest
|
### Check latest
|
||||||
@@ -249,13 +268,13 @@ For Java distributions that are not cached on Hosted images, `check-latest` alwa
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- run: java --version
|
- run: java --version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Testing against different Java versions
|
### Testing against different Java versions
|
||||||
@@ -268,9 +287,9 @@ jobs:
|
|||||||
java: [ '8', '11', '17', '21', '25' ]
|
java: [ '8', '11', '17', '21', '25' ]
|
||||||
name: Java ${{ matrix.Java }} sample
|
name: Java ${{ matrix.Java }} sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- name: Setup java
|
- name: Setup java
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: '<distribution>'
|
distribution: '<distribution>'
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
@@ -279,11 +298,11 @@ jobs:
|
|||||||
|
|
||||||
### Install multiple JDKs
|
### Install multiple JDKs
|
||||||
|
|
||||||
All configured Java versions are added to the PATH. The last one added to the PATH (i.e., the last JDK set up by this action) will be used as the default and available globally. Other Java versions can be accessed through environment variables such as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}'. To use a specific Java version, set the JAVA_HOME environment variable accordingly and prepend its bin directory to the PATH to ensure it takes priority during execution.
|
All configured Java versions are added to the PATH. The last one added to the PATH (i.e., the last JDK set up by this action) will be used as the default and available globally. Other Java versions can be accessed through environment variables such as 'JAVA\_HOME\_{{ MAJOR\_VERSION }}\_{{ ARCHITECTURE }}'. To use a specific Java version, set the JAVA\_HOME environment variable accordingly and prepend its bin directory to the PATH to ensure it takes priority during execution.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: '<distribution>'
|
distribution: '<distribution>'
|
||||||
java-version: |
|
java-version: |
|
||||||
@@ -298,39 +317,31 @@ In the example above multiple JDKs are installed for the same job. The result af
|
|||||||
### Advanced Configuration
|
### Advanced Configuration
|
||||||
|
|
||||||
- [Selecting a Java distribution](docs/advanced-usage.md#Selecting-a-Java-distribution)
|
- [Selecting a Java distribution](docs/advanced-usage.md#Selecting-a-Java-distribution)
|
||||||
- [Eclipse Temurin](docs/advanced-usage.md#Eclipse-Temurin)
|
- [Eclipse Temurin](docs/advanced-usage.md#Eclipse-Temurin)
|
||||||
- [Adopt](docs/advanced-usage.md#Adopt)
|
- [Adopt](docs/advanced-usage.md#Adopt)
|
||||||
- [Zulu](docs/advanced-usage.md#Zulu)
|
- [Zulu](docs/advanced-usage.md#Zulu)
|
||||||
- [Liberica](docs/advanced-usage.md#Liberica)
|
- [Liberica](docs/advanced-usage.md#Liberica)
|
||||||
- [Liberica Native Image Kit](docs/advanced-usage.md#Liberica-Native-Image-Kit)
|
- [Liberica Native Image Kit](docs/advanced-usage.md#Liberica-Native-Image-Kit)
|
||||||
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
||||||
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
||||||
- [Oracle](docs/advanced-usage.md#Oracle)
|
- [Oracle](docs/advanced-usage.md#Oracle)
|
||||||
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
|
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
|
||||||
- [SapMachine](docs/advanced-usage.md#SapMachine)
|
- [SapMachine](docs/advanced-usage.md#SapMachine)
|
||||||
- [GraalVM](docs/advanced-usage.md#GraalVM)
|
- [GraalVM](docs/advanced-usage.md#GraalVM)
|
||||||
- [JetBrains](docs/advanced-usage.md#JetBrains)
|
- [JetBrains](docs/advanced-usage.md#JetBrains)
|
||||||
- [Tencent Kona](docs/advanced-usage.md#Tencent-Kona)
|
- [Tencent Kona](docs/advanced-usage.md#Tencent-Kona)
|
||||||
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
|
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
|
||||||
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
|
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
|
||||||
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
|
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
|
||||||
- [Testing against different Java distributions](docs/advanced-usage.md#Testing-against-different-Java-distributions)
|
- [Testing against different Java distributions](docs/advanced-usage.md#Testing-against-different-Java-distributions)
|
||||||
- [Testing against different platforms](docs/advanced-usage.md#Testing-against-different-platforms)
|
- [Testing against different platforms](docs/advanced-usage.md#Testing-against-different-platforms)
|
||||||
- [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven)
|
- [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven)
|
||||||
|
- [Maven transfer progress (download logs)](docs/advanced-usage.md#maven-transfer-progress-download-logs)
|
||||||
- [Publishing using Gradle](docs/advanced-usage.md#Publishing-using-Gradle)
|
- [Publishing using Gradle](docs/advanced-usage.md#Publishing-using-Gradle)
|
||||||
- [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache)
|
- [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache)
|
||||||
- [Modifying Maven Toolchains](docs/advanced-usage.md#Modifying-Maven-Toolchains)
|
- [Modifying Maven Toolchains](docs/advanced-usage.md#Modifying-Maven-Toolchains)
|
||||||
- [Java Version File](docs/advanced-usage.md#Java-version-file)
|
- [Java Version File](docs/advanced-usage.md#Java-version-file)
|
||||||
|
|
||||||
## V2 vs V1
|
|
||||||
|
|
||||||
Examples in this README use `actions/setup-java@v5`, but the main migration note from V1 still applies to all later major versions (`v2`, `v3`, `v4`, and `v5`):
|
|
||||||
|
|
||||||
- Starting with V2, the action supports custom distributions. V1 supports only Azul Zulu OpenJDK.
|
|
||||||
- Starting with V2, you must specify distribution along with the version. V1 defaults to Azul Zulu OpenJDK, so only version input is required. Follow [the migration guide](docs/switching-to-v2.md) to switch from V1 to V2.
|
|
||||||
|
|
||||||
For information about the latest releases, recent updates, and newly supported distributions, please refer to the `setup-java` [Releases](https://github.com/actions/setup-java/releases).
|
|
||||||
|
|
||||||
## Recommended permissions
|
## Recommended permissions
|
||||||
|
|
||||||
When using the `setup-java` action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality:
|
When using the `setup-java` action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality:
|
||||||
|
|||||||
+84
-2
@@ -228,9 +228,40 @@ describe('auth tests', () => {
|
|||||||
<username>\${env.${username}}</username>
|
<username>\${env.${username}}</username>
|
||||||
<password>\${env.&<>"''"><&}</password>
|
<password>\${env.&<>"''"><&}</password>
|
||||||
</server>
|
</server>
|
||||||
|
</servers>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>setup-java-gpg</id>
|
||||||
|
<properties>
|
||||||
|
<gpg.passphraseEnvName>${gpgPassphrase}</gpg.passphraseEnvName>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
<activeProfiles>
|
||||||
|
<activeProfile>setup-java-gpg</activeProfile>
|
||||||
|
</activeProfiles>
|
||||||
|
</settings>`;
|
||||||
|
|
||||||
|
expect(auth.generate(id, username, password, gpgPassphrase)).toEqual(
|
||||||
|
expectedSettings
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not add a gpg profile when the passphrase env var is the maven-gpg-plugin default', () => {
|
||||||
|
const id = 'packages';
|
||||||
|
const username = 'USER';
|
||||||
|
const password = '&<>"\'\'"><&';
|
||||||
|
const gpgPassphrase = 'MAVEN_GPG_PASSPHRASE';
|
||||||
|
|
||||||
|
const expectedSettings = `<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
<interactiveMode>false</interactiveMode>
|
||||||
|
<servers>
|
||||||
<server>
|
<server>
|
||||||
<id>gpg.passphrase</id>
|
<id>${id}</id>
|
||||||
<passphrase>\${env.${gpgPassphrase}}</passphrase>
|
<username>\${env.${username}}</username>
|
||||||
|
<password>\${env.&<>"''"><&}</password>
|
||||||
</server>
|
</server>
|
||||||
</servers>
|
</servers>
|
||||||
</settings>`;
|
</settings>`;
|
||||||
@@ -239,4 +270,55 @@ describe('auth tests', () => {
|
|||||||
expectedSettings
|
expectedSettings
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('uses deprecated input aliases and warns', () => {
|
||||||
|
const mockGetInput = core.getInput as jest.MockedFunction<
|
||||||
|
typeof core.getInput
|
||||||
|
>;
|
||||||
|
const mockWarning = core.warning as jest.MockedFunction<
|
||||||
|
typeof core.warning
|
||||||
|
>;
|
||||||
|
mockGetInput.mockImplementation(name =>
|
||||||
|
name === 'server-username' ? 'LEGACY_USERNAME' : ''
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
auth.getInputWithDeprecatedAlias(
|
||||||
|
'server-username-env-var',
|
||||||
|
'server-username',
|
||||||
|
'GITHUB_ACTOR'
|
||||||
|
)
|
||||||
|
).toBe('LEGACY_USERNAME');
|
||||||
|
expect(mockWarning).toHaveBeenCalledWith(
|
||||||
|
"The 'server-username' input is deprecated and may be removed in a future release. Please use 'server-username-env-var' instead."
|
||||||
|
);
|
||||||
|
|
||||||
|
mockGetInput.mockReset();
|
||||||
|
mockWarning.mockReset();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prefers the replacement input over its deprecated alias', () => {
|
||||||
|
const mockGetInput = core.getInput as jest.MockedFunction<
|
||||||
|
typeof core.getInput
|
||||||
|
>;
|
||||||
|
mockGetInput.mockImplementation(name => {
|
||||||
|
const inputs: Record<string, string> = {
|
||||||
|
'server-password-env-var': 'NEW_PASSWORD',
|
||||||
|
'server-password': 'LEGACY_PASSWORD'
|
||||||
|
};
|
||||||
|
return inputs[name] || '';
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
auth.getInputWithDeprecatedAlias(
|
||||||
|
'server-password-env-var',
|
||||||
|
'server-password',
|
||||||
|
'GITHUB_TOKEN'
|
||||||
|
)
|
||||||
|
).toBe('NEW_PASSWORD');
|
||||||
|
expect(core.warning).toHaveBeenCalled();
|
||||||
|
|
||||||
|
mockGetInput.mockReset();
|
||||||
|
(core.warning as jest.Mock).mockReset();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+196
-12
@@ -166,10 +166,7 @@ describe('dependency cache', () => {
|
|||||||
|
|
||||||
await restore('maven', '');
|
await restore('maven', '');
|
||||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
[
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
join(os.homedir(), '.m2', 'repository'),
|
|
||||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
expect.any(String)
|
expect.any(String)
|
||||||
);
|
);
|
||||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
@@ -196,10 +193,7 @@ describe('dependency cache', () => {
|
|||||||
|
|
||||||
await restore('maven', '');
|
await restore('maven', '');
|
||||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
[
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
join(os.homedir(), '.m2', 'repository'),
|
|
||||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
expect.any(String)
|
expect.any(String)
|
||||||
);
|
);
|
||||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
@@ -214,10 +208,7 @@ describe('dependency cache', () => {
|
|||||||
|
|
||||||
await restore('maven', '');
|
await restore('maven', '');
|
||||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
[
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
join(os.homedir(), '.m2', 'repository'),
|
|
||||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
expect.any(String)
|
expect.any(String)
|
||||||
);
|
);
|
||||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
@@ -226,6 +217,47 @@ describe('dependency cache', () => {
|
|||||||
expect(spyWarning).not.toHaveBeenCalled();
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
||||||
});
|
});
|
||||||
|
it('restores the maven wrapper distribution cache independently of the main cache', async () => {
|
||||||
|
createDirectory(join(workspace, '.mvn'));
|
||||||
|
createDirectory(join(workspace, '.mvn', 'wrapper'));
|
||||||
|
createFile(
|
||||||
|
join(workspace, '.mvn', 'wrapper', 'maven-wrapper.properties')
|
||||||
|
);
|
||||||
|
|
||||||
|
await restore('maven', '');
|
||||||
|
// Main dependency cache no longer carries the wrapper dists path.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
expect.stringContaining('maven-wrapper')
|
||||||
|
);
|
||||||
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
|
'**/.mvn/wrapper/maven-wrapper.properties'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('skips the maven wrapper cache when no wrapper properties exist', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'));
|
||||||
|
spyGlobHashFiles.mockImplementation((pattern: string) =>
|
||||||
|
Promise.resolve(
|
||||||
|
pattern === '**/.mvn/wrapper/maven-wrapper.properties'
|
||||||
|
? ''
|
||||||
|
: 'hash-stub'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await restore('maven', '');
|
||||||
|
// Only the main dependency cache is restored; the wrapper cache path is
|
||||||
|
// never touched because the project does not use mvnw.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledTimes(1);
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('for gradle', () => {
|
describe('for gradle', () => {
|
||||||
it('throws error if no build.gradle found', async () => {
|
it('throws error if no build.gradle found', async () => {
|
||||||
@@ -282,6 +314,43 @@ describe('dependency cache', () => {
|
|||||||
expect(spyWarning).not.toHaveBeenCalled();
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||||
});
|
});
|
||||||
|
it('restores the gradle wrapper distribution cache independently of the main cache', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'));
|
||||||
|
|
||||||
|
await restore('gradle', '');
|
||||||
|
// Main dependency cache no longer carries the wrapper path.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'caches')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
// Wrapper distribution is restored on its own, keyed only on the
|
||||||
|
// wrapper properties file.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'wrapper')],
|
||||||
|
expect.stringContaining('setup-java-')
|
||||||
|
);
|
||||||
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
|
'**/gradle-wrapper.properties'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('skips the gradle wrapper cache when no wrapper properties exist', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'));
|
||||||
|
spyGlobHashFiles.mockImplementation((pattern: string) =>
|
||||||
|
Promise.resolve(
|
||||||
|
pattern === '**/gradle-wrapper.properties' ? '' : 'hash-stub'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await restore('gradle', '');
|
||||||
|
// Only the main dependency cache is restored; the wrapper cache path is
|
||||||
|
// never touched because the project does not use the gradle wrapper.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledTimes(1);
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'caches')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('for sbt', () => {
|
describe('for sbt', () => {
|
||||||
it('throws error if no build.sbt found', async () => {
|
it('throws error if no build.sbt found', async () => {
|
||||||
@@ -457,6 +526,77 @@ describe('dependency cache', () => {
|
|||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('saves the maven wrapper distribution cache under its own key', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-maven-wrapper':
|
||||||
|
return 'setup-java-maven-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await save('maven');
|
||||||
|
expect(spyCacheSave).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
'setup-java-maven-wrapper-key'
|
||||||
|
);
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('does not save the maven wrapper cache on an exact wrapper hit', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-maven-wrapper':
|
||||||
|
case 'cache-matched-key-maven-wrapper':
|
||||||
|
return 'setup-java-maven-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await save('maven');
|
||||||
|
expect(spyCacheSave).not.toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('does not fail the post step when the wrapper distribution path is missing', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-maven-wrapper':
|
||||||
|
return 'setup-java-maven-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
spyCacheSave.mockImplementation((paths: string[]) =>
|
||||||
|
paths.includes(join(os.homedir(), '.m2', 'wrapper', 'dists'))
|
||||||
|
? Promise.reject(
|
||||||
|
new cache.ValidationError(
|
||||||
|
'Path Validation Error: Path(s) specified in the action for caching do(es) not exist'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
: Promise.resolve(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(save('maven')).resolves.toBeUndefined();
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('for gradle', () => {
|
describe('for gradle', () => {
|
||||||
it('uploads cache even if no build.gradle found', async () => {
|
it('uploads cache even if no build.gradle found', async () => {
|
||||||
@@ -509,6 +649,50 @@ describe('dependency cache', () => {
|
|||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('saves the gradle wrapper distribution cache under its own key', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-gradle-wrapper':
|
||||||
|
return 'setup-java-gradle-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await save('gradle');
|
||||||
|
expect(spyCacheSave).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'wrapper')],
|
||||||
|
'setup-java-gradle-wrapper-key'
|
||||||
|
);
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('does not save the gradle wrapper cache on an exact wrapper hit', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-gradle-wrapper':
|
||||||
|
case 'cache-matched-key-gradle-wrapper':
|
||||||
|
return 'setup-java-gradle-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await save('gradle');
|
||||||
|
expect(spyCacheSave).not.toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'wrapper')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('for sbt', () => {
|
describe('for sbt', () => {
|
||||||
it('uploads cache even if no build.sbt found', async () => {
|
it('uploads cache even if no build.sbt found', async () => {
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
target/
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
buildNumber.properties
|
||||||
|
.mvn/timing.properties
|
||||||
|
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>io.github.actions</groupId>
|
||||||
|
<artifactId>setup-java-maven2-example</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.12.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
target/
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
ThisBuild / scalaVersion := "2.12.15"
|
||||||
|
|
||||||
|
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
|
||||||
Executable
+39
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Assert whether a directory exists, for use in the e2e cache workflows.
|
||||||
|
#
|
||||||
|
# Usage: check-dir.sh <dir> [present|absent]
|
||||||
|
#
|
||||||
|
# present (default): fail if <dir> does NOT exist, otherwise list its contents.
|
||||||
|
# absent: fail if <dir> DOES exist.
|
||||||
|
#
|
||||||
|
# Call with already-expanded paths (e.g. "$HOME/.gradle/caches") to avoid
|
||||||
|
# tilde-expansion pitfalls.
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if [ "$#" -lt 1 ]; then
|
||||||
|
echo "Usage: check-dir.sh <dir> [present|absent]" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
dir=$1
|
||||||
|
mode=${2:-present}
|
||||||
|
|
||||||
|
case "$mode" in
|
||||||
|
present)
|
||||||
|
if [ ! -d "$dir" ]; then
|
||||||
|
echo "::error::The $dir directory does not exist unexpectedly"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ls "$dir"
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
if [ -d "$dir" ]; then
|
||||||
|
echo "::error::The $dir directory exists unexpectedly"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "::error::Unknown mode '$mode' (expected 'present' or 'absent')"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';
|
||||||
|
|
||||||
|
const mockGetInput = jest.fn<(...args: any[]) => any>();
|
||||||
|
const mockInfo = jest.fn<(...args: any[]) => any>();
|
||||||
|
const mockDebug = jest.fn<(...args: any[]) => any>();
|
||||||
|
|
||||||
|
jest.unstable_mockModule('@actions/core', () => ({
|
||||||
|
getInput: mockGetInput,
|
||||||
|
info: mockInfo,
|
||||||
|
debug: mockDebug,
|
||||||
|
warning: jest.fn(),
|
||||||
|
setSecret: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
|
const {configureProblemMatcher} = await import('../src/problem-matcher.js');
|
||||||
|
const {INPUT_PROBLEM_MATCHER} = await import('../src/constants.js');
|
||||||
|
|
||||||
|
describe('configureProblemMatcher', () => {
|
||||||
|
let inputs: Record<string, string>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
inputs = {};
|
||||||
|
mockGetInput.mockImplementation((name: string) => inputs[name] ?? '');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('registers the Java problem matcher by default', () => {
|
||||||
|
configureProblemMatcher('/matchers/java.json');
|
||||||
|
|
||||||
|
expect(mockInfo).toHaveBeenCalledWith('##[add-matcher]/matchers/java.json');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not register the Java problem matcher when disabled', () => {
|
||||||
|
inputs[INPUT_PROBLEM_MATCHER] = 'false';
|
||||||
|
|
||||||
|
configureProblemMatcher('/matchers/java.json');
|
||||||
|
|
||||||
|
expect(mockInfo).not.toHaveBeenCalled();
|
||||||
|
expect(mockDebug).toHaveBeenCalledWith('Java problem matcher is disabled');
|
||||||
|
});
|
||||||
|
});
|
||||||
+16
-5
@@ -46,16 +46,20 @@ inputs:
|
|||||||
file. Default is `github`'
|
file. Default is `github`'
|
||||||
required: false
|
required: false
|
||||||
default: 'github'
|
default: 'github'
|
||||||
server-username:
|
server-username-env-var:
|
||||||
description: 'Environment variable name for the username for authentication
|
description: 'Environment variable name for the username for authentication
|
||||||
to the Apache Maven repository. Default is $GITHUB_ACTOR'
|
to the Apache Maven repository. Default is $GITHUB_ACTOR'
|
||||||
required: false
|
required: false
|
||||||
default: 'GITHUB_ACTOR'
|
server-username:
|
||||||
server-password:
|
description: 'Deprecated alias for server-username-env-var'
|
||||||
|
required: false
|
||||||
|
server-password-env-var:
|
||||||
description: 'Environment variable name for password or token for
|
description: 'Environment variable name for password or token for
|
||||||
authentication to the Apache Maven repository. Default is $GITHUB_TOKEN'
|
authentication to the Apache Maven repository. Default is $GITHUB_TOKEN'
|
||||||
required: false
|
required: false
|
||||||
default: 'GITHUB_TOKEN'
|
server-password:
|
||||||
|
description: 'Deprecated alias for server-password-env-var'
|
||||||
|
required: false
|
||||||
settings-path:
|
settings-path:
|
||||||
description: 'Path to where the settings.xml file will be written. Default is ~/.m2.'
|
description: 'Path to where the settings.xml file will be written. Default is ~/.m2.'
|
||||||
required: false
|
required: false
|
||||||
@@ -67,8 +71,11 @@ inputs:
|
|||||||
description: 'GPG private key to import. Default is empty string.'
|
description: 'GPG private key to import. Default is empty string.'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
gpg-passphrase-env-var:
|
||||||
|
description: 'Environment variable name for the GPG private key passphrase. Defaults to GPG_PASSPHRASE when gpg-private-key is set.'
|
||||||
|
required: false
|
||||||
gpg-passphrase:
|
gpg-passphrase:
|
||||||
description: 'Environment variable name for the GPG private key passphrase. Defaults to GPG_PASSPHRASE when gpg-private-key is set; ignored otherwise.'
|
description: 'Deprecated alias for gpg-passphrase-env-var'
|
||||||
required: false
|
required: false
|
||||||
cache:
|
cache:
|
||||||
description: 'Name of the build platform to cache dependencies. It can be "maven", "gradle" or "sbt".'
|
description: 'Name of the build platform to cache dependencies. It can be "maven", "gradle" or "sbt".'
|
||||||
@@ -94,6 +101,10 @@ inputs:
|
|||||||
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.'
|
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
|
required: false
|
||||||
default: false
|
default: false
|
||||||
|
problem-matcher:
|
||||||
|
description: 'Whether to register the Java problem matcher (compiler errors/warnings and uncaught exceptions). Set to "false" to disable annotations.'
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
outputs:
|
outputs:
|
||||||
distribution:
|
distribution:
|
||||||
description: 'Distribution of Java that has been installed'
|
description: 'Distribution of Java that has been installed'
|
||||||
|
|||||||
Vendored
+1020
-420
File diff suppressed because it is too large
Load Diff
Vendored
+1070
-436
File diff suppressed because it is too large
Load Diff
+394
-354
File diff suppressed because it is too large
Load Diff
+16
-16
@@ -4,13 +4,13 @@ The major breaking change in V2 is the new mandatory `distribution` input. This
|
|||||||
Use the `zulu` keyword if you would like to continue using the same distribution as in V1.
|
Use the `zulu` keyword if you would like to continue using the same distribution as in V1.
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
java-package: jdk # optional (jdk or jre) - defaults to jdk
|
java-package: jdk # optional (jdk or jre) - defaults to jdk
|
||||||
- run: java -cp java HelloWorldApp
|
- run: java -cp java HelloWorldApp
|
||||||
```
|
```
|
||||||
|
|
||||||
**General recommendation** — configure CI with the same distribution that is used on your local dev machine.
|
**General recommendation** — configure CI with the same distribution that is used on your local dev machine.
|
||||||
@@ -19,15 +19,15 @@ steps:
|
|||||||
Since the `distribution` input is required in V2, you should specify it using `jdkfile` to continue installing Java from a local file on the runner
|
Since the `distribution` input is required in V2, you should specify it using `jdkfile` to continue installing Java from a local file on the runner
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- run: |
|
- run: |
|
||||||
download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
|
download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
|
||||||
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
|
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
||||||
java-version: '11.0.0'
|
java-version: '11.0.0'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dropping legacy Java version syntax 1.x
|
## Dropping legacy Java version syntax 1.x
|
||||||
|
|||||||
Generated
+613
-561
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -42,7 +42,7 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^6.1.0",
|
"@actions/cache": "^6.2.0",
|
||||||
"@actions/core": "^3.0.1",
|
"@actions/core": "^3.0.1",
|
||||||
"@actions/exec": "^3.0.0",
|
"@actions/exec": "^3.0.0",
|
||||||
"@actions/glob": "^0.7.0",
|
"@actions/glob": "^0.7.0",
|
||||||
@@ -57,8 +57,8 @@
|
|||||||
"@jest/globals": "^30.4.1",
|
"@jest/globals": "^30.4.1",
|
||||||
"@types/node": "^26.1.1",
|
"@types/node": "^26.1.1",
|
||||||
"@types/semver": "^7.7.0",
|
"@types/semver": "^7.7.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.62.0",
|
"@typescript-eslint/eslint-plugin": "^8.64.0",
|
||||||
"@typescript-eslint/parser": "^8.62.0",
|
"@typescript-eslint/parser": "^8.65.0",
|
||||||
"@vercel/ncc": "^0.44.0",
|
"@vercel/ncc": "^0.44.0",
|
||||||
"eslint": "^10.7.0",
|
"eslint": "^10.7.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
@@ -67,10 +67,10 @@
|
|||||||
"globals": "^17.7.0",
|
"globals": "^17.7.0",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"jest": "^30.4.2",
|
"jest": "^30.4.2",
|
||||||
"lint-staged": "^17.0.8",
|
"lint-staged": "^17.2.0",
|
||||||
"prettier": "^3.9.5",
|
"prettier": "^3.9.5",
|
||||||
"ts-jest": "^29.4.11",
|
"ts-jest": "^29.4.11",
|
||||||
"typescript": "^6.0.3"
|
"typescript": "^7.0.2"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/actions/setup-java/issues"
|
"url": "https://github.com/actions/setup-java/issues"
|
||||||
|
|||||||
+64
-22
@@ -12,8 +12,16 @@ import {getBooleanInput} from './util.js';
|
|||||||
|
|
||||||
export async function configureAuthentication() {
|
export async function configureAuthentication() {
|
||||||
const id = core.getInput(constants.INPUT_SERVER_ID);
|
const id = core.getInput(constants.INPUT_SERVER_ID);
|
||||||
const username = core.getInput(constants.INPUT_SERVER_USERNAME);
|
const usernameEnvVar = getInputWithDeprecatedAlias(
|
||||||
const password = core.getInput(constants.INPUT_SERVER_PASSWORD);
|
constants.INPUT_SERVER_USERNAME_ENV_VAR,
|
||||||
|
constants.INPUT_SERVER_USERNAME_DEPRECATED,
|
||||||
|
constants.INPUT_DEFAULT_SERVER_USERNAME
|
||||||
|
);
|
||||||
|
const passwordEnvVar = getInputWithDeprecatedAlias(
|
||||||
|
constants.INPUT_SERVER_PASSWORD_ENV_VAR,
|
||||||
|
constants.INPUT_SERVER_PASSWORD_DEPRECATED,
|
||||||
|
constants.INPUT_DEFAULT_SERVER_PASSWORD
|
||||||
|
);
|
||||||
const settingsDirectory =
|
const settingsDirectory =
|
||||||
core.getInput(constants.INPUT_SETTINGS_PATH) ||
|
core.getInput(constants.INPUT_SETTINGS_PATH) ||
|
||||||
path.join(os.homedir(), constants.M2_DIR);
|
path.join(os.homedir(), constants.M2_DIR);
|
||||||
@@ -24,9 +32,11 @@ export async function configureAuthentication() {
|
|||||||
const gpgPrivateKey =
|
const gpgPrivateKey =
|
||||||
core.getInput(constants.INPUT_GPG_PRIVATE_KEY) ||
|
core.getInput(constants.INPUT_GPG_PRIVATE_KEY) ||
|
||||||
constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
|
constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
|
||||||
const gpgPassphrase =
|
const gpgPassphraseEnvVar = getInputWithDeprecatedAlias(
|
||||||
core.getInput(constants.INPUT_GPG_PASSPHRASE) ||
|
constants.INPUT_GPG_PASSPHRASE_ENV_VAR,
|
||||||
(gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
|
constants.INPUT_GPG_PASSPHRASE_DEPRECATED,
|
||||||
|
gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined
|
||||||
|
);
|
||||||
|
|
||||||
if (gpgPrivateKey) {
|
if (gpgPrivateKey) {
|
||||||
core.setSecret(gpgPrivateKey);
|
core.setSecret(gpgPrivateKey);
|
||||||
@@ -34,11 +44,11 @@ export async function configureAuthentication() {
|
|||||||
|
|
||||||
await createAuthenticationSettings(
|
await createAuthenticationSettings(
|
||||||
id,
|
id,
|
||||||
username,
|
usernameEnvVar,
|
||||||
password,
|
passwordEnvVar,
|
||||||
settingsDirectory,
|
settingsDirectory,
|
||||||
overwriteSettings,
|
overwriteSettings,
|
||||||
gpgPassphrase
|
gpgPassphraseEnvVar
|
||||||
);
|
);
|
||||||
|
|
||||||
if (gpgPrivateKey) {
|
if (gpgPrivateKey) {
|
||||||
@@ -48,13 +58,30 @@ export async function configureAuthentication() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getInputWithDeprecatedAlias(
|
||||||
|
inputName: string,
|
||||||
|
deprecatedInputName: string,
|
||||||
|
defaultValue?: string
|
||||||
|
): string {
|
||||||
|
const value = core.getInput(inputName);
|
||||||
|
const deprecatedValue = core.getInput(deprecatedInputName);
|
||||||
|
|
||||||
|
if (deprecatedValue) {
|
||||||
|
core.warning(
|
||||||
|
`The '${deprecatedInputName}' input is deprecated and may be removed in a future release. Please use '${inputName}' instead.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value || deprecatedValue || defaultValue || '';
|
||||||
|
}
|
||||||
|
|
||||||
export async function createAuthenticationSettings(
|
export async function createAuthenticationSettings(
|
||||||
id: string,
|
id: string,
|
||||||
username: string,
|
usernameEnvVar: string,
|
||||||
password: string,
|
passwordEnvVar: string,
|
||||||
settingsDirectory: string,
|
settingsDirectory: string,
|
||||||
overwriteSettings: boolean,
|
overwriteSettings: boolean,
|
||||||
gpgPassphrase: string | undefined = undefined
|
gpgPassphraseEnvVar: string | undefined = undefined
|
||||||
) {
|
) {
|
||||||
core.info(`Creating ${constants.MVN_SETTINGS_FILE} with server-id: ${id}`);
|
core.info(`Creating ${constants.MVN_SETTINGS_FILE} with server-id: ${id}`);
|
||||||
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
||||||
@@ -62,7 +89,7 @@ export async function createAuthenticationSettings(
|
|||||||
await io.mkdirP(settingsDirectory);
|
await io.mkdirP(settingsDirectory);
|
||||||
await write(
|
await write(
|
||||||
settingsDirectory,
|
settingsDirectory,
|
||||||
generate(id, username, password, gpgPassphrase),
|
generate(id, usernameEnvVar, passwordEnvVar, gpgPassphraseEnvVar),
|
||||||
overwriteSettings
|
overwriteSettings
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -70,9 +97,9 @@ export async function createAuthenticationSettings(
|
|||||||
// only exported for testing purposes
|
// only exported for testing purposes
|
||||||
export function generate(
|
export function generate(
|
||||||
id: string,
|
id: string,
|
||||||
username: string,
|
usernameEnvVar: string,
|
||||||
password: string,
|
passwordEnvVar: string,
|
||||||
gpgPassphrase?: string | undefined
|
gpgPassphraseEnvVar?: string | undefined
|
||||||
) {
|
) {
|
||||||
const xmlObj: {[key: string]: any} = {
|
const xmlObj: {[key: string]: any} = {
|
||||||
settings: {
|
settings: {
|
||||||
@@ -85,20 +112,35 @@ export function generate(
|
|||||||
server: [
|
server: [
|
||||||
{
|
{
|
||||||
id: id,
|
id: id,
|
||||||
username: `\${env.${username}}`,
|
username: `\${env.${usernameEnvVar}}`,
|
||||||
password: `\${env.${password}}`
|
password: `\${env.${passwordEnvVar}}`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (gpgPassphrase) {
|
// The maven-gpg-plugin reads the passphrase from the environment variable
|
||||||
const gpgServer = {
|
// named by the `gpg.passphraseEnvName` property (default MAVEN_GPG_PASSPHRASE).
|
||||||
id: 'gpg.passphrase',
|
// Only configure it when the requested env var name differs from that default;
|
||||||
passphrase: `\${env.${gpgPassphrase}}`
|
// otherwise the plugin already reads the right variable and no extra settings
|
||||||
|
// are needed. Writing `gpg.passphrase` to settings.xml is deprecated and fails
|
||||||
|
// when the plugin's `bestPractices` mode is enabled.
|
||||||
|
if (
|
||||||
|
gpgPassphraseEnvVar &&
|
||||||
|
gpgPassphraseEnvVar !== constants.MAVEN_GPG_PASSPHRASE_DEFAULT_ENV
|
||||||
|
) {
|
||||||
|
xmlObj.settings.profiles = {
|
||||||
|
profile: {
|
||||||
|
id: constants.GPG_PASSPHRASE_PROFILE_ID,
|
||||||
|
properties: {
|
||||||
|
'gpg.passphraseEnvName': gpgPassphraseEnvVar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xmlObj.settings.activeProfiles = {
|
||||||
|
activeProfile: constants.GPG_PASSPHRASE_PROFILE_ID
|
||||||
};
|
};
|
||||||
xmlObj.settings.servers.server.push(gpgServer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return xmlCreate(xmlObj).end({
|
return xmlCreate(xmlObj).end({
|
||||||
|
|||||||
+185
-9
@@ -12,6 +12,30 @@ const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
|
|||||||
const CACHE_MATCHED_KEY = 'cache-matched-key';
|
const CACHE_MATCHED_KEY = 'cache-matched-key';
|
||||||
const CACHE_KEY_PREFIX = 'setup-java';
|
const CACHE_KEY_PREFIX = 'setup-java';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An additional cache entry that is restored and saved independently of the
|
||||||
|
* main dependency cache. Used for build-tool wrapper distributions that rarely
|
||||||
|
* change (e.g. the Maven wrapper distribution) so that they are not evicted
|
||||||
|
* every time a volatile dependency file such as pom.xml changes. See
|
||||||
|
* https://github.com/actions/setup-java/issues/1095.
|
||||||
|
*/
|
||||||
|
interface AdditionalCache {
|
||||||
|
/**
|
||||||
|
* Short identifier for the cache, used to build its cache key and to scope
|
||||||
|
* the state keys that carry information from restore to save.
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
* Paths that make up this cache entry.
|
||||||
|
*/
|
||||||
|
path: string[];
|
||||||
|
/**
|
||||||
|
* Glob patterns whose hash forms the cache key. If no file matches, the
|
||||||
|
* cache is skipped silently (the project simply does not use this feature).
|
||||||
|
*/
|
||||||
|
pattern: string[];
|
||||||
|
}
|
||||||
|
|
||||||
interface PackageManager {
|
interface PackageManager {
|
||||||
id: 'maven' | 'gradle' | 'sbt';
|
id: 'maven' | 'gradle' | 'sbt';
|
||||||
/**
|
/**
|
||||||
@@ -19,27 +43,36 @@ interface PackageManager {
|
|||||||
*/
|
*/
|
||||||
path: string[];
|
path: string[];
|
||||||
pattern: string[];
|
pattern: string[];
|
||||||
|
/**
|
||||||
|
* Additional caches keyed independently of the main dependency cache.
|
||||||
|
*/
|
||||||
|
additionalCaches?: AdditionalCache[];
|
||||||
}
|
}
|
||||||
const supportedPackageManager: PackageManager[] = [
|
const supportedPackageManager: PackageManager[] = [
|
||||||
{
|
{
|
||||||
id: 'maven',
|
id: 'maven',
|
||||||
path: [
|
path: [join(os.homedir(), '.m2', 'repository')],
|
||||||
join(os.homedir(), '.m2', 'repository'),
|
|
||||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
||||||
pattern: [
|
pattern: [
|
||||||
'**/pom.xml',
|
'**/pom.xml',
|
||||||
'**/.mvn/wrapper/maven-wrapper.properties',
|
'**/.mvn/wrapper/maven-wrapper.properties',
|
||||||
'**/.mvn/extensions.xml'
|
'**/.mvn/extensions.xml'
|
||||||
|
],
|
||||||
|
// The Maven wrapper distribution only depends on the wrapper properties,
|
||||||
|
// which change very rarely, so it is cached separately from the local
|
||||||
|
// repository. This keeps it available across the frequent pom.xml changes
|
||||||
|
// that rotate the main cache key. See issue #1095.
|
||||||
|
additionalCaches: [
|
||||||
|
{
|
||||||
|
name: 'maven-wrapper',
|
||||||
|
path: [join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
pattern: ['**/.mvn/wrapper/maven-wrapper.properties']
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'gradle',
|
id: 'gradle',
|
||||||
path: [
|
path: [join(os.homedir(), '.gradle', 'caches')],
|
||||||
join(os.homedir(), '.gradle', 'caches'),
|
|
||||||
join(os.homedir(), '.gradle', 'wrapper')
|
|
||||||
],
|
|
||||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
||||||
pattern: [
|
pattern: [
|
||||||
'**/*.gradle*',
|
'**/*.gradle*',
|
||||||
@@ -48,6 +81,17 @@ const supportedPackageManager: PackageManager[] = [
|
|||||||
'buildSrc/**/Dependencies.kt',
|
'buildSrc/**/Dependencies.kt',
|
||||||
'gradle/*.versions.toml',
|
'gradle/*.versions.toml',
|
||||||
'**/versions.properties'
|
'**/versions.properties'
|
||||||
|
],
|
||||||
|
// The Gradle wrapper distribution only depends on the wrapper properties,
|
||||||
|
// which change very rarely, so it is cached separately from the Gradle
|
||||||
|
// caches. This keeps it available across the frequent *.gradle* changes
|
||||||
|
// that rotate the main cache key. See issue #269.
|
||||||
|
additionalCaches: [
|
||||||
|
{
|
||||||
|
name: 'gradle-wrapper',
|
||||||
|
path: [join(os.homedir(), '.gradle', 'wrapper')],
|
||||||
|
pattern: ['**/gradle-wrapper.properties']
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -87,6 +131,21 @@ function findPackageManager(id: string): PackageManager {
|
|||||||
return packageManager;
|
return packageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State keys used to carry an additional cache's restore-time information over
|
||||||
|
* to the post (save) action, scoped by the additional cache name.
|
||||||
|
*/
|
||||||
|
function additionalCachePrimaryKeyState(name: string): string {
|
||||||
|
return `${STATE_CACHE_PRIMARY_KEY}-${name}`;
|
||||||
|
}
|
||||||
|
function additionalCacheMatchedKeyState(name: string): string {
|
||||||
|
return `${CACHE_MATCHED_KEY}-${name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildCacheKey(id: string, fileHash: string): string {
|
||||||
|
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${id}-${fileHash}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that generates a cache key to use.
|
* A function that generates a cache key to use.
|
||||||
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
||||||
@@ -105,7 +164,22 @@ async function computeCacheKey(
|
|||||||
`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
|
`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
|
return buildCacheKey(packageManager.id, fileHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the cache key for an additional cache. Unlike {@link computeCacheKey}
|
||||||
|
* this returns undefined (instead of throwing) when no file matches the pattern,
|
||||||
|
* because additional caches are optional features that many projects do not use.
|
||||||
|
*/
|
||||||
|
async function computeAdditionalCacheKey(
|
||||||
|
additionalCache: AdditionalCache
|
||||||
|
): Promise<string | undefined> {
|
||||||
|
const fileHash = await glob.hashFiles(additionalCache.pattern.join('\n'));
|
||||||
|
if (!fileHash) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return buildCacheKey(additionalCache.name, fileHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,6 +204,40 @@ export async function restore(id: string, cacheDependencyPath: string) {
|
|||||||
core.setOutput('cache-hit', false);
|
core.setOutput('cache-hit', false);
|
||||||
core.info(`${packageManager.id} cache is not found`);
|
core.info(`${packageManager.id} cache is not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const additionalCache of packageManager.additionalCaches ?? []) {
|
||||||
|
await restoreAdditionalCache(additionalCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore an additional cache (e.g. a build-tool wrapper distribution) that is
|
||||||
|
* keyed independently of the main dependency cache so that it survives changes
|
||||||
|
* to volatile dependency files. Skips silently when the project does not use
|
||||||
|
* the corresponding feature.
|
||||||
|
*/
|
||||||
|
async function restoreAdditionalCache(additionalCache: AdditionalCache) {
|
||||||
|
const primaryKey = await computeAdditionalCacheKey(additionalCache);
|
||||||
|
if (!primaryKey) {
|
||||||
|
core.debug(
|
||||||
|
`No file matched [${additionalCache.pattern}] for the ${additionalCache.name} cache, skipping.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.debug(`${additionalCache.name} primary key is ${primaryKey}`);
|
||||||
|
core.saveState(
|
||||||
|
additionalCachePrimaryKeyState(additionalCache.name),
|
||||||
|
primaryKey
|
||||||
|
);
|
||||||
|
|
||||||
|
const matchedKey = await cache.restoreCache(additionalCache.path, primaryKey);
|
||||||
|
if (matchedKey) {
|
||||||
|
core.saveState(
|
||||||
|
additionalCacheMatchedKeyState(additionalCache.name),
|
||||||
|
matchedKey
|
||||||
|
);
|
||||||
|
core.info(`${additionalCache.name} cache restored from key: ${matchedKey}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,6 +251,10 @@ export async function save(id: string) {
|
|||||||
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
||||||
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
||||||
|
|
||||||
|
for (const additionalCache of packageManager.additionalCaches ?? []) {
|
||||||
|
await saveAdditionalCache(packageManager, additionalCache);
|
||||||
|
}
|
||||||
|
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
core.warning('Error retrieving key from state.');
|
core.warning('Error retrieving key from state.');
|
||||||
return;
|
return;
|
||||||
@@ -180,6 +292,70 @@ export async function save(id: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save an additional cache under its own key. Skips when no key was recorded at
|
||||||
|
* restore time (feature unused) or when the exact key was already restored.
|
||||||
|
*/
|
||||||
|
async function saveAdditionalCache(
|
||||||
|
packageManager: PackageManager,
|
||||||
|
additionalCache: AdditionalCache
|
||||||
|
) {
|
||||||
|
const primaryKey = core.getState(
|
||||||
|
additionalCachePrimaryKeyState(additionalCache.name)
|
||||||
|
);
|
||||||
|
const matchedKey = core.getState(
|
||||||
|
additionalCacheMatchedKeyState(additionalCache.name)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!primaryKey) {
|
||||||
|
// The feature is not used by this project, nothing to save.
|
||||||
|
core.debug(
|
||||||
|
`No primary key for the ${additionalCache.name} cache, not saving cache.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
} else if (matchedKey === primaryKey) {
|
||||||
|
core.info(
|
||||||
|
`Cache hit occurred on the ${additionalCache.name} primary key ${primaryKey}, not saving cache.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const cacheId = await cache.saveCache(additionalCache.path, primaryKey);
|
||||||
|
if (cacheId === -1) {
|
||||||
|
core.debug(
|
||||||
|
`${additionalCache.name} cache was not saved for the key: ${primaryKey}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.info(
|
||||||
|
`${additionalCache.name} cache saved with the key: ${primaryKey}`
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
const err = error as Error;
|
||||||
|
|
||||||
|
if (err.name === cache.ValidationError.name) {
|
||||||
|
// The cache paths did not resolve, e.g. the wrapper distribution was
|
||||||
|
// never downloaded because a system build tool was used or the download
|
||||||
|
// failed. Optional wrapper caches must not fail the post step, so skip.
|
||||||
|
core.debug(
|
||||||
|
`${additionalCache.name} cache paths do not exist, not saving cache: ${err.message}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err.name === cache.ReserveCacheError.name) {
|
||||||
|
core.info(err.message);
|
||||||
|
} else {
|
||||||
|
if (isProbablyGradleDaemonProblem(packageManager, err)) {
|
||||||
|
core.warning(
|
||||||
|
'Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param packageManager the specified package manager by user
|
* @param packageManager the specified package manager by user
|
||||||
* @param error the error thrown by the saveCache
|
* @param error the error thrown by the saveCache
|
||||||
|
|||||||
+17
-3
@@ -8,19 +8,33 @@ export const INPUT_JDK_FILE = 'jdk-file';
|
|||||||
export const INPUT_JDK_FILE_DEPRECATED = 'jdkFile';
|
export const INPUT_JDK_FILE_DEPRECATED = '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_SET_DEFAULT = 'set-default';
|
||||||
|
export const INPUT_PROBLEM_MATCHER = 'problem-matcher';
|
||||||
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||||
export const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
export const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
||||||
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_ENV_VAR = 'server-username-env-var';
|
||||||
export const INPUT_SERVER_PASSWORD = 'server-password';
|
export const INPUT_SERVER_PASSWORD_ENV_VAR = 'server-password-env-var';
|
||||||
|
export const INPUT_SERVER_USERNAME_DEPRECATED = 'server-username';
|
||||||
|
export const INPUT_SERVER_PASSWORD_DEPRECATED = 'server-password';
|
||||||
export const INPUT_SETTINGS_PATH = 'settings-path';
|
export const INPUT_SETTINGS_PATH = 'settings-path';
|
||||||
export const INPUT_OVERWRITE_SETTINGS = 'overwrite-settings';
|
export const INPUT_OVERWRITE_SETTINGS = 'overwrite-settings';
|
||||||
export const INPUT_GPG_PRIVATE_KEY = 'gpg-private-key';
|
export const INPUT_GPG_PRIVATE_KEY = 'gpg-private-key';
|
||||||
export const INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
|
export const INPUT_GPG_PASSPHRASE_ENV_VAR = 'gpg-passphrase-env-var';
|
||||||
|
export const INPUT_GPG_PASSPHRASE_DEPRECATED = 'gpg-passphrase';
|
||||||
|
|
||||||
|
export const INPUT_DEFAULT_SERVER_USERNAME = 'GITHUB_ACTOR';
|
||||||
|
export const INPUT_DEFAULT_SERVER_PASSWORD = 'GITHUB_TOKEN';
|
||||||
export const INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
|
export const INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
|
||||||
export const INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
export const INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
||||||
|
|
||||||
|
// The default name of the environment variable the maven-gpg-plugin reads the
|
||||||
|
// passphrase from (property `gpg.passphraseEnvName`). When the configured
|
||||||
|
// passphrase env var name matches this, no extra configuration is required.
|
||||||
|
export const MAVEN_GPG_PASSPHRASE_DEFAULT_ENV = 'MAVEN_GPG_PASSPHRASE';
|
||||||
|
|
||||||
|
// Id of the settings.xml profile used to set `gpg.passphraseEnvName`.
|
||||||
|
export const GPG_PASSPHRASE_PROFILE_ID = 'setup-java-gpg';
|
||||||
|
|
||||||
export const INPUT_CACHE = 'cache';
|
export const INPUT_CACHE = 'cache';
|
||||||
export const INPUT_CACHE_DEPENDENCY_PATH = 'cache-dependency-path';
|
export const INPUT_CACHE_DEPENDENCY_PATH = 'cache-dependency-path';
|
||||||
export const INPUT_JOB_STATUS = 'job-status';
|
export const INPUT_JOB_STATUS = 'job-status';
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import {INPUT_PROBLEM_MATCHER} from './constants.js';
|
||||||
|
import {getBooleanInput} from './util.js';
|
||||||
|
|
||||||
|
export function configureProblemMatcher(matcherPath: string): void {
|
||||||
|
const problemMatcherEnabled = getBooleanInput(INPUT_PROBLEM_MATCHER, true);
|
||||||
|
|
||||||
|
if (!problemMatcherEnabled) {
|
||||||
|
core.debug('Java problem matcher is disabled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
core.info(`##[add-matcher]${matcherPath}`);
|
||||||
|
}
|
||||||
+2
-1
@@ -14,6 +14,7 @@ import {fileURLToPath} from 'url';
|
|||||||
import {getJavaDistribution} from './distributions/distribution-factory.js';
|
import {getJavaDistribution} from './distributions/distribution-factory.js';
|
||||||
import {JavaInstallerOptions} from './distributions/base-models.js';
|
import {JavaInstallerOptions} from './distributions/base-models.js';
|
||||||
import {configureMavenArgs} from './maven-args.js';
|
import {configureMavenArgs} from './maven-args.js';
|
||||||
|
import {configureProblemMatcher} from './problem-matcher.js';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
@@ -120,7 +121,7 @@ async function run() {
|
|||||||
'..',
|
'..',
|
||||||
'.github'
|
'.github'
|
||||||
);
|
);
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
configureProblemMatcher(path.join(matchersPath, 'java.json'));
|
||||||
|
|
||||||
await auth.configureAuthentication();
|
await auth.configureAuthentication();
|
||||||
configureMavenArgs();
|
configureMavenArgs();
|
||||||
|
|||||||
Reference in New Issue
Block a user