Skip to content

Commit 4445327

Browse files
authored
bbenz Update java-build.yml
Set JDK to 11 or 17
1 parent f959256 commit 4445327

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

‎.github/workflows/java-build.yml‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Build Java Semantic Kernel
22

3+
# Triggers the workflow on manual dispatch, push, and pull request events
4+
# for the specified branches and paths
35
on:
46
workflow_dispatch:
57
push:
@@ -15,6 +17,7 @@ permissions:
1517
contents: read
1618

1719
jobs:
20+
# Determines if Java files have changed
1821
paths-filter:
1922
runs-on: ubuntu-latest
2023
outputs:
@@ -28,55 +31,49 @@ jobs:
2831
java:
2932
- 'java/**'
3033
- '**/java/**'
31-
# run only if 'java' files were changed
3234
- name: java tests
3335
if: steps.filter.outputs.java == 'true'
3436
run: echo "Java file"
35-
# run only if not 'java' files were changed
3637
- name: not java tests
3738
if: steps.filter.outputs.java != 'true'
3839
run: echo "NOT java file"
40+
41+
# Builds and tests the Java project
3942
java-build:
4043
runs-on: ubuntu-latest
4144
needs: paths-filter
4245
if: needs.paths-filter.outputs.javaChanges == 'true'
4346
strategy:
4447
fail-fast: false
4548
matrix:
46-
java-versions: [8, 17]
49+
# Defines a matrix strategy for JDK versions 11 and 17
50+
java-versions: [11, 17]
4751

4852
name: Java CI on JDK${{ matrix.java-versions }}
4953

5054
steps:
5155
- name: Checkout
5256
uses: actions/checkout@v3
5357

54-
# Need to use JDK 11 to build for JDK 8
55-
- name: Set JDK
56-
id: set-jdk
57-
shell: bash
58-
run: |
59-
if [[ ${{ matrix.java-versions }} == 8 ]]; then
60-
echo "JDK_VERSION=11" >> $GITHUB_OUTPUT
61-
else
62-
version=${{ matrix.java-versions }}
63-
echo "JDK_VERSION=$version" >> $GITHUB_OUTPUT
64-
fi
65-
66-
- uses: actions/setup-java@v3
58+
# Sets up the specified JDK version from the matrix
59+
- name: Set up JDK ${{ matrix.java-versions }}
60+
uses: actions/setup-java@v3
6761
with:
68-
java-version: ${{ steps.set-jdk.outputs.JDK_VERSION }}
62+
java-version: ${{ matrix.java-versions }}
6963
distribution: microsoft
7064
cache: maven
7165

66+
# Builds the project with Maven using the matrix JDK version
7267
- name: Build with Maven
7368
run: ./mvnw -B -Pbug-check -DskipTests -Pcompile-jdk${{ matrix.java-versions }} clean install --file pom.xml
7469
working-directory: java
7570

71+
# Runs tests with Maven using the matrix JDK version
7672
- name: Run tests
7773
run: ./mvnw -B -Pbug-check -Pcompile-jdk${{ matrix.java-versions }} test --file pom.xml
7874
working-directory: java
7975

76+
# Uploads test artifacts for each JDK version
8077
- uses: actions/upload-artifact@v2
8178
if: always()
8279
with:

0 commit comments

Comments
 (0)