Skip to content

Commit 05ce6f3

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

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+
# JDK 11 is required for Maven itself as runtime
23+
- name: Set up JDK
24+
uses: actions/setup-java@v3
25+
with:
26+
distribution: zulu
27+
java-version: |
28+
6
29+
11
30+
- name: Setup Maven
31+
run: |
32+
mkdir -p .mvn
33+
echo "-B" > .mvn/maven.config
34+
- name: Compile with Java 6
35+
run: mvn clean compile -Dmaven.toolchains.jdk.id=zulu_6 -P java-6,!legacy-java,!modern-java
36+
- name: Run Tests with Java 6
37+
run: mvn test -Dmaven.toolchains.jdk.id=zulu_6 -P java-6,!legacy-java,!modern-java
38+
- name: Build Test Report for Java 6
39+
if: ${{ always() }}
40+
run: |
41+
mvn surefire-report:report-only
42+
mvn site -DgenerateReports=false
43+
- name: Upload Test Results for Java 6
44+
if: ${{ always() }}
45+
uses: actions/upload-artifact@v3
46+
with:
47+
name: Test Results for Java 6
48+
path: target/surefire-reports/
49+
- name: Upload Test Report 6
50+
if: ${{ always() }}
51+
uses: actions/upload-artifact@v3
52+
with:
53+
name: Test Report for Java 6
54+
path: target/site/
55+
56+
build:
57+
runs-on: ubuntu-latest
58+
strategy:
59+
matrix:
60+
java: [ 8, 11, 17 ]
61+
name: Java ${{ matrix.java }}
62+
steps:
63+
- name: Check out Git repository
64+
uses: actions/checkout@v3
65+
- name: Set up JDK
66+
uses: actions/setup-java@v3
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)