-
Notifications
You must be signed in to change notification settings - Fork 110
84 lines (77 loc) · 3.16 KB
/
maven.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 6, 8, 11, 17 ]
name: Build with Java ${{ matrix.java }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 6
if: ${{ matrix.java == '6'}}
# We use v1 as newer versions do not seem to support Java 6
# Inspired by https://github.com/junit-team/junit4/blob/main/.github/workflows/main.yml
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
mvn-toolchain-id: ${{ matrix.java }}
- name: Set up toolchains.xml for Java 6
# We need to manually set up toolchains.xml as setup-java@v1 does not seem to support toolchains.xml
if: ${{ matrix.java == '6'}}
run: |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" >> $HOME/.m2/toolchains.xml
echo "<toolchains>" >> $HOME/.m2/toolchains.xml
echo " <toolchain>" >> $HOME/.m2/toolchains.xml
echo " <type>jdk</type>" >> $HOME/.m2/toolchains.xml
echo " <provides>" >> $HOME/.m2/toolchains.xml
echo " <version>6</version>" >> $HOME/.m2/toolchains.xml
echo " </provides>" >> $HOME/.m2/toolchains.xml
echo " <configuration>" >> $HOME/.m2/toolchains.xml
echo " <jdkHome>${JAVA_HOME_6_0_119_X64}</jdkHome>" >> $HOME/.m2/toolchains.xml
echo " </configuration>" >> $HOME/.m2/toolchains.xml
echo " </toolchain>" >> $HOME/.m2/toolchains.xml
echo "</toolchains>" >> $HOME/.m2/toolchains.xml
cat $HOME/.m2/toolchains.xml
- name: Set up JDK
if: ${{ matrix.java != '6'}}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
mvn-toolchain-id: ${{ matrix.java }}
distribution: temurin
cache: maven
- name: Set up JDK 17
# Set up JDK 17 as the last step before building so it becomes default and Maven would use it
uses: actions/setup-java@v3
with:
java-version: 17
mvn-toolchain-id: 17
distribution: temurin
cache: maven
- name: Build on Java 6, run tests with Java 17
# Java 6 is special case, we need to activate a profile on it
if: ${{ matrix.java == '6'}}
run: |
chmod +x mvnw
./mvnw -ntp -B -P java6 -DtestJdk=17 test
- name: Build on Java 8, run tests with Java 17
# Java 8 is also a special case, we need to activate a profile on it
if: ${{ matrix.java == '8'}}
run: |
chmod +x mvnw
./mvnw -ntp -B -P java8 -DtestJdk=17 test
- name: Build and test on Java ${{ matrix.java }}
# More modern JDKs support specifying a target JDK release for the compiler
if: ${{ matrix.java != '6' && matrix.java != '8' }}
run: |
chmod +x mvnw
./mvnw -ntp -B -DmainJdk=${{ matrix.java }} verify package
mkdir upload && cp target/*.jar upload
- uses: actions/upload-artifact@v3
with:
name: Upload artifacts
path: upload