Skip to content

Commit 4fb1cb8

Browse files
committed
add GitHub Actions workflow to verify builds and pull requests
1 parent 7414e90 commit 4fb1cb8

File tree

2 files changed

+139
-3
lines changed

2 files changed

+139
-3
lines changed

.github/workflows/main.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Java CI with Maven
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build-6:
17+
runs-on: ubuntu-latest
18+
name: Java 6
19+
steps:
20+
- name: Check out Git repository
21+
uses: actions/checkout@v3
22+
- name: Set up JDK
23+
uses: actions/setup-java@master
24+
with:
25+
distribution: zulu
26+
java-version: |
27+
6
28+
11
29+
- name: Setup Maven
30+
run: |
31+
mkdir -p .mvn
32+
echo "-B" > .mvn/maven.config
33+
- name: Compile with Java 6
34+
run: mvn clean compile -Dmaven.toolchains.jdk.id=zulu_6 -P java-6,!legacy-java,!modern-java
35+
- name: Run Tests with Java 6
36+
run: mvn test -Dmaven.toolchains.jdk.id=zulu_6 -P java-6,!legacy-java,!modern-java
37+
- name: Build Test Report for Java 6
38+
if: ${{ always() }}
39+
run: |
40+
mvn surefire-report:report-only
41+
mvn site -DgenerateReports=false
42+
- name: Upload Test Results for Java 6
43+
if: ${{ always() }}
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: Test Results for Java 6
47+
path: target/surefire-reports/
48+
- name: Upload Test Report 6
49+
if: ${{ always() }}
50+
uses: actions/upload-artifact@v3
51+
with:
52+
name: Test Report for Java 6
53+
path: target/site/
54+
55+
build:
56+
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
java: [ 8, 11, 17 ]
60+
name: Java ${{ matrix.java }}
61+
steps:
62+
- name: Check out Git repository
63+
uses: actions/checkout@v3
64+
# Set up an alternative JDK to be used with Maven; using master to support Toolchains Output
65+
- name: Set up JDK
66+
uses: actions/setup-java@master
67+
with:
68+
distribution: zulu
69+
java-version: ${{ matrix.java }}
70+
- name: Setup Maven
71+
run: |
72+
mkdir -p .mvn
73+
echo "-B" > .mvn/maven.config
74+
- name: Compile with Java ${{ matrix.java }}
75+
run: mvn clean compile
76+
- name: Run Tests with Java ${{ matrix.java }}
77+
run: mvn test
78+
- name: Build Test Report for Java ${{ matrix.java }}
79+
if: ${{ always() }}
80+
run: |
81+
mvn surefire-report:report-only
82+
mvn site -DgenerateReports=false
83+
- name: Upload Test Results for Java ${{ matrix.java }}
84+
if: ${{ always() }}
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: Test Results for Java ${{ matrix.java }}
88+
path: target/surefire-reports/
89+
- name: Upload Test Report ${{ matrix.java }}
90+
if: ${{ always() }}
91+
uses: actions/upload-artifact@v3
92+
with:
93+
name: Test Report for Java ${{ matrix.java }}
94+
path: target/site/

pom.xml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,26 @@
6767
<plugin>
6868
<groupId>org.apache.maven.plugins</groupId>
6969
<artifactId>maven-compiler-plugin</artifactId>
70-
<version>2.3.1</version>
70+
<version>3.10.1</version>
71+
</plugin>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-toolchains-plugin</artifactId>
75+
<version>3.1.0</version>
76+
<executions>
77+
<execution>
78+
<phase>validate</phase>
79+
<goals>
80+
<goal>toolchain</goal>
81+
</goals>
82+
</execution>
83+
</executions>
7184
<configuration>
72-
<source>1.6</source>
73-
<target>1.6</target>
85+
<toolchains>
86+
<jdk>
87+
<version>[1.6,)</version>
88+
</jdk>
89+
</toolchains>
7490
</configuration>
7591
</plugin>
7692
<plugin>
@@ -115,6 +131,32 @@
115131
</distributionManagement>
116132

117133
<profiles>
134+
<profile>
135+
<id>java-6</id>
136+
<properties>
137+
<maven.compiler.source>1.6</maven.compiler.source>
138+
<maven.compiler.target>1.6</maven.compiler.target>
139+
</properties>
140+
</profile>
141+
<profile>
142+
<id>legacy-java</id>
143+
<activation>
144+
<jdk>(,8]</jdk>
145+
</activation>
146+
<properties>
147+
<maven.compiler.source>${java.specification.version}</maven.compiler.source>
148+
<maven.compiler.target>${java.specification.version}</maven.compiler.target>
149+
</properties>
150+
</profile>
151+
<profile>
152+
<id>modern-java</id>
153+
<activation>
154+
<jdk>[9,)</jdk>
155+
</activation>
156+
<properties>
157+
<maven.compiler.release>${java.specification.version}</maven.compiler.release>
158+
</properties>
159+
</profile>
118160
<profile>
119161
<id>release-sign-artifacts</id>
120162
<activation>

0 commit comments

Comments
 (0)