Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit 456f9d5

Browse files
gildaytylernhoward
authored andcommitted
⬆️ Test With Java LTS 11, 17, 21
* Upgrade Maven plugins and dependencies to support executing the build on Java 22. * Use Maven Toolchains to run the unit tests on Java 11, since they use junit-4 APIs that not support newer Java versions. * Use Maven Toolchains to run integration tests on LTS versions 11, 17, and 21. * Upgrade GitHub Actions to use newer versions that integrate with Maven Toolchains.
1 parent b668fd5 commit 456f9d5

File tree

5 files changed

+57
-22
lines changed

5 files changed

+57
-22
lines changed

Diff for: .github/workflows/build.yml

+8-12
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,22 @@ jobs:
1111
name: Verify
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515

16-
- uses: actions/setup-java@v2
16+
- uses: actions/setup-java@v4
1717
with:
1818
java-version: 11
1919
distribution: temurin
2020

21-
- name: Cache Maven Wrapper
22-
uses: actions/cache@v2
21+
- uses: actions/setup-java@v4
2322
with:
24-
path: ./.mvn/wrapper/maven-wrapper.jar
25-
key: ${{ runner.os }}-maven-wrapper-${{ hashFiles('./.mvn/wrapper/maven-wrapper.properties') }}
26-
restore-keys: ${{ runner.os }}-maven-wrapper
23+
java-version: 17
24+
distribution: temurin
2725

28-
- name: Cache Maven Repository
29-
uses: actions/cache@v2
26+
- uses: actions/setup-java@v4
3027
with:
31-
path: ~/.m2/repository
32-
key: ${{ runner.os }}-m2-repository-${{ hashFiles('**/pom.xml') }}
33-
restore-keys: ${{ runner.os }}-m2-repository
28+
java-version: 21
29+
distribution: temurin
3430

3531
- name: Maven Verify
3632
env:

Diff for: README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ Available on [Maven Central](https://search.maven.org/search?q=a:contrast-maven-
99

1010
## Building
1111

12-
Requires JDK 11 to build
12+
Requires JDK 21 to build.
13+
14+
Tests require JDK 11 and 17 to be set-up in [Maven
15+
Toolchains](https://maven.apache.org/guides/mini/guide-using-toolchains.html)
16+
and requires that Maven be on the `PATH`.
1317

1418
Use `./mvnw verify` to build and test changes to the project
1519

Diff for: pom.xml

+42-7
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
<properties>
6565
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6666
<contrast.test-repository>${project.build.directory}/test-repository</contrast.test-repository>
67-
<junit-jupiter.version>5.7.2</junit-jupiter.version>
68-
<junit-vintage-engine.version>5.7.2</junit-vintage-engine.version>
67+
<junit-jupiter.version>5.11.0</junit-jupiter.version>
68+
<junit-vintage-engine.version>5.11.0</junit-vintage-engine.version>
6969
<auto-value.version>1.6.3</auto-value.version>
7070
</properties>
7171

@@ -136,7 +136,7 @@
136136
<dependency>
137137
<groupId>org.mockito</groupId>
138138
<artifactId>mockito-core</artifactId>
139-
<version>3.11.2</version>
139+
<version>5.13.0</version>
140140
<scope>test</scope>
141141
</dependency>
142142
<!-- TODO[JG] Migrate from JUnit 4 -->
@@ -338,11 +338,16 @@
338338
</plugin>
339339
<plugin>
340340
<artifactId>maven-surefire-plugin</artifactId>
341-
<version>2.22.2</version>
341+
<version>3.5.0</version>
342+
<configuration>
343+
<jdkToolchain>
344+
<version>11</version>
345+
</jdkToolchain>
346+
</configuration>
342347
</plugin>
343348
<plugin>
344349
<artifactId>maven-failsafe-plugin</artifactId>
345-
<version>2.22.2</version>
350+
<version>3.5.0</version>
346351
<configuration>
347352
<!-- never use legacy JUnit tests for new integration tests -->
348353
<classpathDependencyExcludes>
@@ -400,7 +405,7 @@
400405
<plugin>
401406
<groupId>com.diffplug.spotless</groupId>
402407
<artifactId>spotless-maven-plugin</artifactId>
403-
<version>2.21.0</version>
408+
<version>2.43.0</version>
404409
<configuration>
405410
<formats>
406411
<format>
@@ -418,7 +423,7 @@
418423
</formats>
419424
<java>
420425
<googleJavaFormat>
421-
<version>1.15.0</version>
426+
<version>1.17.0</version>
422427
</googleJavaFormat>
423428
<removeUnusedImports/>
424429
</java>
@@ -609,10 +614,40 @@
609614
<artifactId>maven-failsafe-plugin</artifactId>
610615
<executions>
611616
<execution>
617+
<id>jdk-11</id>
618+
<goals>
619+
<goal>integration-test</goal>
620+
<goal>verify</goal>
621+
</goals>
622+
<configuration>
623+
<jdkToolchain>
624+
<version>11</version>
625+
</jdkToolchain>
626+
</configuration>
627+
</execution>
628+
<execution>
629+
<id>jdk-17</id>
612630
<goals>
613631
<goal>integration-test</goal>
614632
<goal>verify</goal>
615633
</goals>
634+
<configuration>
635+
<jdkToolchain>
636+
<version>17</version>
637+
</jdkToolchain>
638+
</configuration>
639+
</execution>
640+
<execution>
641+
<id>jdk-21</id>
642+
<goals>
643+
<goal>integration-test</goal>
644+
<goal>verify</goal>
645+
</goals>
646+
<configuration>
647+
<jdkToolchain>
648+
<version>21</version>
649+
</jdkToolchain>
650+
</configuration>
616651
</execution>
617652
</executions>
618653
<configuration>

Diff for: src/main/java/com/contrastsecurity/maven/plugin/ContrastScanMojo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private Path findProjectArtifactOrFail() throws MojoFailureException {
210210
final File file = artifact == null ? null : artifact.getFile();
211211
if (file == null) {
212212
throw new MojoFailureException(
213-
"Project's artifact file has not ben set - see https://contrastsecurity.dev/contrast-maven-plugin/troubleshooting/artifact-not-set.html");
213+
"Project's artifact file has not been set - see https://contrastsecurity.dev/contrast-maven-plugin/troubleshooting/artifact-not-set.html");
214214
}
215215
return file.toPath();
216216
}

Diff for: src/test/java/com/contrastsecurity/maven/plugin/it/ContrastScanMojoIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ void fails_when_no_artifact_detected(final ContrastAPI contrast)
6767

6868
// THEN plugin fails because there is no artifact to scan
6969
verifier.verifyTextInLog(
70-
"Project's artifact file has not ben set - see https://contrastsecurity.dev/contrast-maven-plugin/troubleshooting/artifact-not-set.html");
70+
"Project's artifact file has not been set - see https://contrastsecurity.dev/contrast-maven-plugin/troubleshooting/artifact-not-set.html");
7171
}
7272
}

0 commit comments

Comments
 (0)