Support building with Java 17
Some checks failed
Java CI with Maven / build (17) (push) Successful in 1m50s
Java CI with Gradle / build (17) (push) Failing after 1m59s

Needed to remove ErrorProne and Nullaway compiler plugins

Fixes #2136
This commit is contained in:
Dave Syer 2025-11-26 10:38:36 +00:00
parent fc1c7490ed
commit 828940e5a1
7 changed files with 20 additions and 78 deletions

View file

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '25' ]
java: [ '17' ]
steps:
- uses: actions/checkout@v4

View file

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '25' ]
java: [ '17' ]
steps:
- uses: actions/checkout@v4

View file

@ -1,10 +0,0 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED

View file

@ -1,3 +0,0 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=25-librca

View file

@ -14,7 +14,7 @@ See the presentation here:
## Run Petclinic locally
Spring Petclinic is a [Spring Boot](https://spring.io/guides/gs/spring-boot) application built using [Maven](https://spring.io/guides/gs/maven/) or [Gradle](https://spring.io/guides/gs/gradle/).
Java 25 or later is required for the build, but the application can run with Java 17 or newer:
Java 17 or later is required for the build, and the application can run with Java 17 or newer:
```bash
git clone https://github.com/spring-projects/spring-petclinic.git

View file

@ -7,7 +7,6 @@ plugins {
id 'org.cyclonedx.bom' version '3.0.2'
id 'io.spring.javaformat' version '0.0.47'
id "io.spring.nohttp" version "0.0.11"
id 'net.ltgt.errorprone' version '4.3.0'
}
gradle.startParameter.excludedTaskNames += [ "checkFormatAot", "checkFormatAotTest" ]
@ -17,7 +16,7 @@ version = '4.0.0-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
languageVersion = JavaLanguageVersion.of(17)
}
}
@ -30,14 +29,12 @@ ext.springJavaformatCheckstyleVersion = "0.0.47"
ext.webjarsLocatorLiteVersion = "1.1.2"
ext.webjarsFontawesomeVersion = "4.7.0"
ext.webjarsBootstrapVersion = "5.3.8"
ext.errorProneVersion = "2.42.0"
ext.nullAwayVersion = "0.12.10"
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'javax.cache:cache-api'
implementation 'jakarta.xml.bind:jakarta.xml.bind-api'
@ -59,8 +56,6 @@ dependencies {
testImplementation 'org.testcontainers:testcontainers-mysql'
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${springJavaformatCheckstyleVersion}"
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
errorprone "com.google.errorprone:error_prone_core:${errorProneVersion}"
errorprone "com.uber.nullaway:nullaway:${nullAwayVersion}"
}
tasks.named('test') {
@ -77,21 +72,6 @@ checkstyleNohttp {
configFile = file('src/checkstyle/nohttp-checkstyle.xml')
}
tasks.withType(JavaCompile).configureEach {
options.release = 17
options.errorprone {
disableAllChecks = true
}
if (name.equals("compileJava")) {
options.errorprone {
error("NullAway")
option("NullAway:OnlyNullMarked", "true")
option("NullAway:CustomContractAnnotations", "org.springframework.lang.Contract")
option("NullAway:JSpecifyMode", "true")
}
}
}
tasks.named("formatMain").configure { dependsOn("checkstyleMain") }
tasks.named("formatMain").configure { dependsOn("checkstyleNohttp") }

55
pom.xml
View file

@ -18,12 +18,11 @@
<properties>
<!-- Generic properties -->
<java.version>25</java.version>
<maven.compiler.release>17</maven.compiler.release>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Important for reproducible builds. Update using e.g. ./mvnw versions:set -DnewVersion=... -->
<project.build.outputTimestamp>2025-11-22T16:15:42Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2024-11-28T14:37:52Z</project.build.outputTimestamp>
<!-- Web dependencies -->
<webjars-locator.version>1.1.2</webjars-locator.version>
@ -31,14 +30,13 @@
<webjars-font-awesome.version>4.7.0</webjars-font-awesome.version>
<checkstyle.version>12.1.2</checkstyle.version>
<error-prone.version>2.42.0</error-prone.version>
<jacoco.version>0.8.14</jacoco.version>
<libsass.version>0.3.4</libsass.version>
<lifecycle-mapping>1.0.0</lifecycle-mapping>
<maven-checkstyle.version>3.6.0</maven-checkstyle.version>
<nohttp-checkstyle.version>0.0.11</nohttp-checkstyle.version>
<nullaway.version>0.12.10</nullaway.version>
<spring-format.version>0.0.47</spring-format.version>
</properties>
<dependencies>
@ -57,7 +55,7 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -67,6 +65,16 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-restclient</artifactId>
<scope>test</scope>
</dependency>
<!-- Databases - Uses H2 by default -->
<dependency>
@ -115,9 +123,8 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
@ -284,38 +291,6 @@
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-XDcompilePolicy=simple</arg>
<arg>--should-stop=ifError=FLOW</arg>
<arg>-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true -XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract -XepOpt:NullAway:JSpecifyMode=true</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>${error-prone.version}</version>
</path>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>${nullaway.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
<!-- Spring Boot Actuator displays sbom-related information if a CycloneDX SBOM file is
present at the classpath -->
<plugin>