Skip to content

Raise the build plugins and Lombok processor path that Java 25 needs, and keep Gradle 9 builds configuring - #1234

Open
jkschneider wants to merge 4 commits into
mainfrom
java25-build-reach
Open

Raise the build plugins and Lombok processor path that Java 25 needs, and keep Gradle 9 builds configuring#1234
jkschneider wants to merge 4 commits into
mainfrom
java25-build-reach

Conversation

@jkschneider

Copy link
Copy Markdown
Member

What went wrong

UpgradeToJava25 was applied to ten real Maven and Gradle repositories under Apache, Netflix and Spring Cloud that compiled cleanly on JDK 8/17 beforehand. Afterwards none of them built on JDK 25. The failures fall into three groups:

  1. Build plugins that cannot load on JDK 25 were left alone. maven-enforcer-plugin 1.1.1/1.4 dies with ExceptionInInitializerError before the first module compiles (stanbol, incubator-batchee), maven-assembly-plugin 2.6 reports No such archiver: 'zip' (sdap-mudrod), maven-plugin-plugin 3.6.1 fails with Unsupported class file major version 69 (olingo-odata4), and the checkstyle 8.45 that incubator-hugegraph-toolchain pins on maven-checkstyle-plugin cannot parse the pattern-matching switch that UpgradeToJava21 writes (unexpected token: results ->). Lombok belongs here as well: JDK 23 stopped running annotation processors found on the classpath, and although EnableLombokAnnotationProcessor exists for exactly that, its ModuleHasDependency precondition only marks the module that declares Lombok. AddAnnotationProcessor writes the processor path into the reactor parent's pluginManagement, a pom that precondition never marks, so every multi-module build (rocketmq-schema-registry, incubator-hugegraph-toolchain) compiled without Lombok and failed on the getters and log fields it should have generated.
  2. Gradle builds broke on the wrapper bump itself. The wrapper moves to 9.1.0, and Gradle 9 removed the JavaPluginConvention, so a build that assigns sourceCompatibility on the project (eureka's subprojects { sourceCompatibility = 1.8 }) now fails with Could not set unknown property 'sourceCompatibility', even though the recipe had just rewritten that very line to 25.
  3. Source rewritten past the module's compiler level. In one batch run the module-level and property-indirected compiler declarations (<release>${project.build.release.version}</release> in a parent's pluginManagement, <source>1.6</source> in a parent, maven.compiler.source properties) stayed behind while the sources gained switch expressions, pattern-matching instanceof and IO.println. Re-running the recipe against the same checkouts raised every one of those declarations, so this could not be reproduced in the recipe itself; the shapes are now pinned down by tests so a regression shows up here first.

What changed

  • UpgradePluginsForJava25 raises maven-enforcer-plugin to 3.x, maven-assembly-plugin to 3.x, maven-plugin-plugin to 3.15.x and maven-checkstyle-plugin to 3.6.x, and bumps a com.puppycrawl.tools:checkstyle pinned as a plugin dependency to 10.x, the first line whose parser accepts the Java 21 syntax the migration introduces.
  • EnableLombokAnnotationProcessor is gated on a new ModuleOrParentHasDependency precondition, which marks the modules that depend on Lombok and the in-reactor parent poms they inherit from, so AddAnnotationProcessor reaches the pom it targets.
  • UpgradePluginsForJava25 runs org.openrewrite.gradle.gradle9.UseJavaExtensionBlock right after the wrapper bump, so sourceCompatibility / targetCompatibility assigned at project level (including inside subprojects { } / allprojects { }) move into the java { } block before Gradle 9 rejects them.
  • UpgradeJavaVersionTest gains multi-module cases for a compiler level inherited from the parent's pluginManagement, literally, through a custom property, and through the maven.compiler.* properties with test-source overrides.

What is left for the reader

  • Plugin versions managed by a parent outside the repository. olingo-odata4 declares maven-plugin-plugin without a version and inherits 3.6.1 from org.apache:apache:30; UpgradePluginVersion honours the remote pluginManagement even with addVersionIfMissing, so the bump does not land and the build still fails at helpmojo. Filed as UpgradePluginVersion cannot raise a plugin whose version is managed by a parent outside the repository rewrite#8775 rather than worked around here.

  • JAXB in incubator-batchee. Once the enforcer no longer crashes, jbatch fails on javax.xml.bind.annotation not existing; AddJaxbDependenciesWithRuntime did not add the dependency to that module. That is a Java 11 migration gap unrelated to this change.

  • Non-Java build plugins. incubator-hugegraph-toolchain now compiles its Java modules and stops in hugegraph-spark-connector on org.scala-tools:maven-scala-plugin 2.15.2, a long-abandoned Scala plugin with no drop-in successor coordinate.

  • Gradle plugins compiled against removed Gradle APIs. eureka's com.netflix.nebula.netflixoss 11.6.0 needs org.gradle.util.VersionNumber, and Hystrix's own buildSrc plugin references org.gradle.util.ConfigureUtil; both were removed in Gradle 9. Gradle 8.x does not run on JDK 25, so stopping the wrapper short is not an option, and rewriting third-party or in-repo plugin code is beyond a version bump. MigrateToGradle9 in rewrite-gradle carries the rest of the script-level migration and can be layered on top; the plugin code has to be updated by hand.

  • Kotlin 1.x modules. spring-cloud-sleuth's kotlin-maven-plugin 1.6.21 throws IllegalArgumentException: 25 when the compiler itself is started on JDK 25. The recipe deliberately does not cross the Kotlin 2.0 boundary, so such modules stay on a JDK 24 toolchain by design; building them with a JDK 25 requires the Kotlin bump first.

  • A newer checkstyle can report new violations. Raising the checkstyle line to one that parses Java 21 also enables checks the old version did not have; rocketmq-schema-registry now fails UnnecessaryParentheses on untouched code after the plugin moved from 2.17 to 3.6.0. That is a style decision for the project rather than something the migration can settle.

Verification against real repositories

Each repository was reset, the recipe applied from a locally built jar, and the project compiled on JDK 25 (mvn compile / ./gradlew testClasses), before and after this change.

Repository Before this change After this change
apache/sdap-mudrod exit 1: maven-assembly-plugin:2.6 No such archiver: 'zip' exit 0 (maven-assembly-plugin 3.8.0)
apache/incubator-batchee exit 1: maven-enforcer-plugin:1.1.1 ExceptionInInitializerError on the parent exit 1, but the enforcer runs and every module before jbatch compiles; jbatch fails on the missing JAXB dependency described above
apache/rocketmq-schema-registry exit 1: checkstyle UnnecessaryParentheses on untouched code; with -Dcheckstyle.skip, exit 1 on Lombok-generated log, getters and constructors exit 0 with -Dcheckstyle.skip (Lombok now runs); the checkstyle style finding remains
apache/incubator-hugegraph-toolchain exit 1: checkstyle 8.45 unexpected token: results -> exit 1, but checkstyle passes and hugegraph-client / hugegraph-loader compile; stops at maven-scala-plugin:2.15.2 in hugegraph-spark-connector
apache/olingo-odata4 exit 1: maven-plugin-plugin:3.6.1 Unsupported class file major version 69 exit 1, unchanged; the version is managed by org.apache:apache:30 (openrewrite/rewrite#8775)
spring-cloud/spring-cloud-sleuth exit 1: kotlin-maven-plugin:1.6.21 IllegalArgumentException: 25 not re-run; Kotlin 1.x stays where it is by design
Netflix/eureka, Netflix/Hystrix exit 1: sourceCompatibility unknown property / org.gradle.util.ConfigureUtil under Gradle 9.1 not re-run; the sourceCompatibility half is covered by the new unit test, the plugin code is out of reach
apache/stanbol exit 1: maven-enforcer-plugin:1.4 ExceptionInInitializerError on the parent not re-run; the same enforcer line is exercised by incubator-batchee

UpgradeJavaVersionTest and UpgradeToJava25Test pass in full.

…on tests

A module whose compiler level lives in the parent's pluginManagement, either
literally or through a custom property, must be raised with the parent.
maven-enforcer-plugin 1.x, maven-assembly-plugin 2.x and maven-plugin-plugin
3.6 fail at startup on JDK 25, and a checkstyle pinned on
maven-checkstyle-plugin must parse the pattern-matching switch the Java 21
migration writes.
…the Gradle 9 wrapper

Gradle 9 removed the JavaPluginConvention, so a build that assigned
sourceCompatibility on the project stopped configuring once the wrapper moved.
JDK 23 stopped running annotation processors found on the classpath, so
AddAnnotationProcessor writes the lombok path into the parent's
pluginManagement. A per-module precondition never marked that parent pom, so
multi-module builds kept compiling without Lombok on JDK 25.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant