Skip to content

Commit 57d4f88

Browse files
authored
Java EA GitHub Actions improvements (mapstruct#3803)
* Use Java 17 for building MapStruct (still Java 8 compatible) * Upgrade to Spring 6 for tests * Adjust excludes and min tests version for some integration tests
1 parent e0a7d3d commit 57d4f88

36 files changed

Lines changed: 96 additions & 63 deletions

File tree

.github/workflows/java-ea.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ env:
77

88
jobs:
99
test_jdk_ea:
10-
strategy:
11-
fail-fast: false
12-
matrix:
13-
java: [19-ea]
14-
name: 'Linux JDK ${{ matrix.java }}'
10+
name: 'Linux JDK EA'
1511
runs-on: ubuntu-latest
1612
steps:
1713
- name: 'Checkout'

.github/workflows/main.yml

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,68 +24,61 @@ jobs:
2424
distribution: 'zulu'
2525
java-version: ${{ matrix.java }}
2626
- name: 'Test'
27-
run: ./mvnw ${MAVEN_ARGS} -Djacoco.skip=true install -DskipDistribution=true
28-
linux:
29-
name: 'Linux JDK 11'
30-
runs-on: ubuntu-latest
31-
steps:
32-
- name: 'Checkout'
33-
uses: actions/checkout@v3
34-
- name: 'Set up JDK 11'
35-
uses: actions/setup-java@v3
36-
with:
37-
distribution: 'zulu'
38-
java-version: 11
39-
- name: 'Test'
40-
run: ./mvnw ${MAVEN_ARGS} install
27+
run: ./mvnw ${MAVEN_ARGS} -Djacoco.skip=${{ matrix.java != 17 }} install -DskipDistribution=${{ matrix.java != 17 }}
4128
- name: 'Generate coverage report'
29+
if: matrix.java == 17
4230
run: ./mvnw jacoco:report
4331
- name: 'Upload coverage to Codecov'
32+
if: matrix.java == 17
4433
uses: codecov/codecov-action@v2
4534
- name: 'Publish Snapshots'
46-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'mapstruct/mapstruct'
35+
if: matrix.java == 17 && github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'mapstruct/mapstruct'
4736
run: ./mvnw -s etc/ci-settings.xml -DskipTests=true -DskipDistribution=true deploy
48-
linux-jdk-8:
49-
name: 'Linux JDK 8'
37+
integration_test_jdk:
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
java: [ 8, 11 ]
42+
name: 'Linux JDK ${{ matrix.java }}'
5043
runs-on: ubuntu-latest
5144
steps:
5245
- name: 'Checkout'
5346
uses: actions/checkout@v3
54-
- name: 'Set up JDK 11 for building everything'
47+
- name: 'Set up JDK 17 for building everything'
5548
uses: actions/setup-java@v3
5649
with:
5750
distribution: 'zulu'
58-
java-version: 11
51+
java-version: 17
5952
- name: 'Install Processor'
6053
run: ./mvnw ${MAVEN_ARGS} -DskipTests install -pl processor -am
61-
- name: 'Set up JDK 8 for running integration tests'
54+
- name: 'Set up JDK ${{ matrix.java }} for running integration tests'
6255
uses: actions/setup-java@v3
6356
with:
6457
distribution: 'zulu'
65-
java-version: 8
58+
java-version: ${{ matrix.java }}
6659
- name: 'Run integration tests'
6760
run: ./mvnw ${MAVEN_ARGS} verify -pl integrationtest
6861
windows:
6962
name: 'Windows'
7063
runs-on: windows-latest
7164
steps:
7265
- uses: actions/checkout@v3
73-
- name: 'Set up JDK 11'
66+
- name: 'Set up JDK 17'
7467
uses: actions/setup-java@v3
7568
with:
7669
distribution: 'zulu'
77-
java-version: 11
70+
java-version: 17
7871
- name: 'Test'
7972
run: ./mvnw %MAVEN_ARGS% install
8073
mac:
8174
name: 'Mac OS'
8275
runs-on: macos-latest
8376
steps:
8477
- uses: actions/checkout@v3
85-
- name: 'Set up JDK 11'
78+
- name: 'Set up JDK 17'
8679
uses: actions/setup-java@v3
8780
with:
8881
distribution: 'zulu'
89-
java-version: 11
82+
java-version: 17
9083
- name: 'Test'
9184
run: ./mvnw ${MAVEN_ARGS} install

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup Java
2323
uses: actions/setup-java@v4
2424
with:
25-
java-version: 11
25+
java-version: 17
2626
distribution: 'zulu'
2727
cache: maven
2828

integrationtest/src/test/java/org/mapstruct/itest/tests/FullFeatureCompilationExclusionCliEnhancer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public Collection<String> getAdditionalCommandLineArguments(ProcessorTest.Proces
3030

3131
switch ( currentJreVersion ) {
3232
case JAVA_8:
33+
additionalExcludes.add( "org/mapstruct/ap/test/**/spring/**/*.java" );
3334
additionalExcludes.add( "org/mapstruct/ap/test/injectionstrategy/cdi/**/*.java" );
3435
additionalExcludes.add( "org/mapstruct/ap/test/injectionstrategy/jakarta_cdi/**/*.java" );
3536
additionalExcludes.add( "org/mapstruct/ap/test/annotatewith/deprecated/jdk11/*.java" );
@@ -42,6 +43,8 @@ public Collection<String> getAdditionalCommandLineArguments(ProcessorTest.Proces
4243
// TODO find out why this fails:
4344
additionalExcludes.add( "org/mapstruct/ap/test/collection/wildcard/BeanMapper.java" );
4445
break;
46+
case JAVA_11:
47+
additionalExcludes.add( "org/mapstruct/ap/test/**/spring/**/*.java" );
4548
default:
4649
}
4750

integrationtest/src/test/java/org/mapstruct/itest/tests/MavenIntegrationTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
package org.mapstruct.itest.tests;
77

8+
import org.junit.jupiter.api.condition.DisabledOnJre;
89
import org.junit.jupiter.api.condition.EnabledForJreRange;
910
import org.junit.jupiter.api.condition.JRE;
1011
import org.junit.jupiter.api.parallel.Execution;
@@ -80,12 +81,15 @@ void jakartaJaxbTest() {
8081
}
8182

8283
@ProcessorTest(baseDir = "jsr330Test")
84+
@EnabledForJreRange(min = JRE.JAVA_17)
85+
@DisabledOnJre(JRE.OTHER)
8386
void jsr330Test() {
8487
}
8588

8689
@ProcessorTest(baseDir = "lombokBuilderTest", processorTypes = {
8790
ProcessorTest.ProcessorType.JAVAC
8891
})
92+
@DisabledOnJre(JRE.OTHER)
8993
void lombokBuilderTest() {
9094
}
9195

@@ -94,6 +98,7 @@ void lombokBuilderTest() {
9498
ProcessorTest.ProcessorType.JAVAC_WITH_PATHS
9599
})
96100
@EnabledForJreRange(min = JRE.JAVA_11)
101+
@DisabledOnJre(JRE.OTHER)
97102
void lombokModuleTest() {
98103
}
99104

@@ -150,6 +155,7 @@ void expressionTextBlocksTest() {
150155
}, forkJvm = true)
151156
// We have to fork the jvm because there is an NPE in com.intellij.openapi.util.SystemInfo.getRtVersion
152157
// and the kotlin-maven-plugin uses that. See also https://youtrack.jetbrains.com/issue/IDEA-238907
158+
@DisabledOnJre(JRE.OTHER)
153159
void kotlinDataTest() {
154160
}
155161

@@ -163,6 +169,8 @@ void defaultPackageTest() {
163169
}
164170

165171
@ProcessorTest(baseDir = "springTest")
172+
@EnabledForJreRange(min = JRE.JAVA_17)
173+
@DisabledOnJre(JRE.OTHER)
166174
void springTest() {
167175
}
168176

integrationtest/src/test/java/org/mapstruct/itest/testutil/extension/ProcessorInvocationInterceptor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,20 @@ private void addAdditionalCliArguments(Verifier verifier)
134134
}
135135

136136
private void configureProcessor(Verifier verifier) {
137-
String compilerId = processorTestContext.getProcessor().getCompilerId();
137+
ProcessorTest.ProcessorType processor = processorTestContext.getProcessor();
138+
String compilerId = processor.getCompilerId();
138139
if ( compilerId != null ) {
139-
String profile = processorTestContext.getProcessor().getProfile();
140+
String profile = processor.getProfile();
140141
if ( profile == null ) {
141142
profile = "generate-via-compiler-plugin";
142143
}
143144
verifier.addCliOption( "-P" + profile );
144145
verifier.addCliOption( "-Dcompiler-id=" + compilerId );
146+
if ( processor == ProcessorTest.ProcessorType.JAVAC ) {
147+
if ( CURRENT_VERSION.ordinal() >= JRE.JAVA_21.ordinal() ) {
148+
verifier.addCliOption( "-Dmaven.compiler.proc=full" );
149+
}
150+
}
145151
}
146152
else {
147153
verifier.addCliOption( "-Pgenerate-via-processor-plugin" );

integrationtest/src/test/resources/fullFeatureTest/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<additionalExclude4>x</additionalExclude4>
2828
<additionalExclude5>x</additionalExclude5>
2929
<additionalExclude6>x</additionalExclude6>
30+
<additionalExclude7>x</additionalExclude7>
31+
<additionalExclude8>x</additionalExclude8>
32+
<additionalExclude9>x</additionalExclude9>
33+
<additionalExclude10>x</additionalExclude10>
34+
<additionalExclude11>x</additionalExclude11>
3035
</properties>
3136

3237
<build>
@@ -49,6 +54,11 @@
4954
<exclude>${additionalExclude4}</exclude>
5055
<exclude>${additionalExclude5}</exclude>
5156
<exclude>${additionalExclude6}</exclude>
57+
<exclude>${additionalExclude7}</exclude>
58+
<exclude>${additionalExclude8}</exclude>
59+
<exclude>${additionalExclude9}</exclude>
60+
<exclude>${additionalExclude10}</exclude>
61+
<exclude>${additionalExclude11}</exclude>
5262
</excludes>
5363
</configuration>
5464
</plugin>

integrationtest/src/test/resources/superTypeGenerationTest/generator/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
<plugin>
3333
<groupId>org.apache.maven.plugins</groupId>
3434
<artifactId>maven-compiler-plugin</artifactId>
35-
<version>3.1</version>
3635
<configuration>
3736
<compilerArgs>
3837
<compilerArg>-proc:none</compilerArg>

integrationtest/src/test/resources/superTypeGenerationTest/usage/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
<plugin>
3939
<groupId>org.apache.maven.plugins</groupId>
4040
<artifactId>maven-compiler-plugin</artifactId>
41-
<version>3.1</version>
4241
<configuration>
4342
<compilerArgs>
4443
<compilerArg>-XprintProcessorInfo</compilerArg>

integrationtest/src/test/resources/targetTypeGenerationTest/generator/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
<plugin>
3333
<groupId>org.apache.maven.plugins</groupId>
3434
<artifactId>maven-compiler-plugin</artifactId>
35-
<version>3.1</version>
3635
<configuration>
3736
<compilerArgs>
3837
<compilerArg>-proc:none</compilerArg>

0 commit comments

Comments
 (0)