bbenz Update java-build.yml

Set JDK to 11 or 17
This commit is contained in:
Brian Benz
2024-01-25 16:07:29 -08:00
committed by GitHub
parent f959256229
commit 44453276a9
+14 -17
View File
@@ -1,5 +1,7 @@
name: Build Java Semantic Kernel
# Triggers the workflow on manual dispatch, push, and pull request events
# for the specified branches and paths
on:
workflow_dispatch:
push:
@@ -15,6 +17,7 @@ permissions:
contents: read
jobs:
# Determines if Java files have changed
paths-filter:
runs-on: ubuntu-latest
outputs:
@@ -28,14 +31,14 @@ jobs:
java:
- 'java/**'
- '**/java/**'
# run only if 'java' files were changed
- name: java tests
if: steps.filter.outputs.java == 'true'
run: echo "Java file"
# run only if not 'java' files were changed
- name: not java tests
if: steps.filter.outputs.java != 'true'
run: echo "NOT java file"
# Builds and tests the Java project
java-build:
runs-on: ubuntu-latest
needs: paths-filter
@@ -43,7 +46,8 @@ jobs:
strategy:
fail-fast: false
matrix:
java-versions: [8, 17]
# Defines a matrix strategy for JDK versions 11 and 17
java-versions: [11, 17]
name: Java CI on JDK${{ matrix.java-versions }}
@@ -51,32 +55,25 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
# Need to use JDK 11 to build for JDK 8
- name: Set JDK
id: set-jdk
shell: bash
run: |
if [[ ${{ matrix.java-versions }} == 8 ]]; then
echo "JDK_VERSION=11" >> $GITHUB_OUTPUT
else
version=${{ matrix.java-versions }}
echo "JDK_VERSION=$version" >> $GITHUB_OUTPUT
fi
- uses: actions/setup-java@v3
# Sets up the specified JDK version from the matrix
- name: Set up JDK ${{ matrix.java-versions }}
uses: actions/setup-java@v3
with:
java-version: ${{ steps.set-jdk.outputs.JDK_VERSION }}
java-version: ${{ matrix.java-versions }}
distribution: microsoft
cache: maven
# Builds the project with Maven using the matrix JDK version
- name: Build with Maven
run: ./mvnw -B -Pbug-check -DskipTests -Pcompile-jdk${{ matrix.java-versions }} clean install --file pom.xml
working-directory: java
# Runs tests with Maven using the matrix JDK version
- name: Run tests
run: ./mvnw -B -Pbug-check -Pcompile-jdk${{ matrix.java-versions }} test --file pom.xml
working-directory: java
# Uploads test artifacts for each JDK version
- uses: actions/upload-artifact@v2
if: always()
with: