Repository navigation
Conversation
…I artifacts (apache#14163) Introduces JakartaEeApiMigrationStrategy, a new mvnup upgrade strategy that detects and migrates legacy Java EE API Maven dependencies to their Jakarta EE equivalents. Java 11 (JEP 320) removed several Java EE modules from the JDK that were previously bundled in rt.jar: JAXB (javax.xml.bind), JAX-WS (javax.xml.ws), javax.annotation, javax.activation, and javax.jws. Projects that declared these APIs as explicit Maven dependencies (javax.xml.bind:jaxb-api, etc.) will fail to compile on JDK 11+ until they migrate to the standalone Jakarta EE equivalents. This strategy: - Scans <dependencies>, <dependencyManagement>, profile dependencies, and plugin-level dependencies for the known legacy Java EE artifact coordinates - Replaces matched entries with the last Jakarta EE release that preserves the javax.* package namespace (source-compatible, no import changes required) - Updates the version element in-place when explicitly declared; leaves it untouched when version is managed via dependencyManagement Migration table (legacy → Jakarta EE replacement): javax.xml.bind:jaxb-api → jakarta.xml.bind:jakarta.xml.bind-api:2.3.3 com.sun.xml.bind:jaxb-core → org.glassfish.jaxb:jaxb-core:2.3.0.1 com.sun.xml.bind:jaxb-impl → org.glassfish.jaxb:jaxb-runtime:2.3.9 javax.xml.ws:jaxws-api → jakarta.xml.ws:jakarta.xml.ws-api:2.3.3 javax.jws:javax.jws-api → jakarta.jws:jakarta.jws-api:1.1.1 javax.annotation:javax.annotation-api → jakarta.annotation:jakarta.annotation-api:1.3.5 javax.activation:activation → jakarta.activation:jakarta.activation-api:1.2.2 javax.activation:javax.activation-api → jakarta.activation:jakarta.activation-api:1.2.2 Note: this covers the case where projects explicitly declare these artifacts. Projects relying purely on rt.jar without declaring the dependency will still need manual intervention (toolchain injection or explicit dep addition). Fixes apache#14163
|
I'm not sure if this is really a task of the mvnup tool. edit: and changing the deps is not enough. The imports in Java code needs to be changed, config files need to be changed as well due the namespace change. |
gnodet-bot
left a comment
There was a problem hiding this comment.
Well-structured new strategy that correctly follows the existing mvnup pattern (e.g. NashornCompatibilityStrategy). Two real issues to address before merge.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| if (versionElement != null) { | ||
| versionElement.textContent(replacement.version()); | ||
| } |
There was a problem hiding this comment.
If the POM declares <version>${jaxb.version}</version>, this code replaces the property expression with a literal version string — silently destroying property-managed version coordination across the reactor. PluginUpgradeStrategy already handles this by detecting ${...} patterns and updating <properties> instead, or skipping with a warning.
This strategy should do the same:
| if (versionElement != null) { | |
| versionElement.textContent(replacement.version()); | |
| } | |
| Element versionElement = dependency.childElement(VERSION).orElse(null); | |
| if (versionElement != null) { | |
| String currentVersion = versionElement.textContentTrimmed(); | |
| if (currentVersion != null && currentVersion.startsWith("${") && currentVersion.endsWith("}")) { | |
| context.warning("Version of " + key + " is controlled by property " | |
| + currentVersion + " — update the property value manually to " | |
| + replacement.version()); | |
| } else { | |
| versionElement.textContent(replacement.version()); | |
| } | |
| } |
| context.warning(key + " uses APIs that were removed from the JDK in Java 11 (JEP 320)." | ||
| + " Replaced with " + replacement.groupId() + ":" + replacement.artifactId() + ":" | ||
| + replacement.version() | ||
| + " which provides the same API as a standalone dependency."); |
There was a problem hiding this comment.
🔸 Low: context.warning() after migration is not actionable
This warning fires after the migration is already complete — the user has nothing to act on. context.detail() on line 307 already logs the migration. Per Maven convention, WARN should only be used when the user can/should do something in response. This is a migration log entry, not a warning.
| context.warning(key + " uses APIs that were removed from the JDK in Java 11 (JEP 320)." | |
| + " Replaced with " + replacement.groupId() + ":" + replacement.artifactId() + ":" | |
| + replacement.version() | |
| + " which provides the same API as a standalone dependency."); | |
| context.detail(key + " uses APIs that were removed from the JDK in Java 11 (JEP 320)." | |
| + " Replaced with " + replacement.groupId() + ":" + replacement.artifactId() + ":" | |
| + replacement.version() | |
| + " which provides the same API as a standalone dependency."); |
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
🔹 Low: No test for plugin-level dependency migration
The strategy traverses <build><plugins><plugin><dependencies> and profile plugin dependencies (see production code), but no test verifies migration in those code paths. The existing tests only cover <dependencies> and <dependencyManagement>. Consider adding a test with a POM that has a legacy JEE artifact in a plugin's <dependencies>.
|
Just to clarify on the package concern: the replacements in this PR target the last Jakarta EE
No import changes are needed — these are drop-in replacements at the Maven coordinate level only. The I'm open to dropping this PR if the scope is considered too broad for |
Summary
Introduces
JakartaEeApiMigrationStrategy, a newmvnupupgrade strategy thatdetects and migrates legacy Java EE API Maven dependencies to their Jakarta EE
equivalents.
Root Cause
Java 11 (JEP 320) removed several Java EE modules from the JDK that were
previously bundled in
rt.jar: JAXB (javax.xml.bind), JAX-WS (javax.xml.ws),javax.annotation,javax.activation, andjavax.jws. Projects that declaredthese APIs as explicit Maven dependencies (e.g.
javax.xml.bind:jaxb-api) willfail to compile on JDK 11+ unless they migrate to the standalone Jakarta EE
equivalents.
mvnuppreviously had no handling for these JEP 320 removed APIs. The existingToolchainPluginStrategyonly acts on JEP 182 retired source levels (≤7) anddoes not detect JEP 320-removed API usage even when
source=8is declared.Fix
The new
JakartaEeApiMigrationStrategy(priority 16, runs alongsideToolchainPluginStrategy) scans all dependency sections in each POM file:<dependencies><dependencyManagement><dependencies><dependencies>and<dependencyManagement><dependencies>(e.g.maven-antrun-plugin)When a legacy Java EE artifact is found, it is replaced in-place with the
last Jakarta EE release that preserves the
javax.*package namespace — makingit source-compatible without requiring import changes:
javax.xml.bind:jaxb-apijakarta.xml.bind:jakarta.xml.bind-api:2.3.3com.sun.xml.bind:jaxb-coreorg.glassfish.jaxb:jaxb-core:2.3.0.1com.sun.xml.bind:jaxb-implorg.glassfish.jaxb:jaxb-runtime:2.3.9javax.xml.ws:jaxws-apijakarta.xml.ws:jakarta.xml.ws-api:2.3.3javax.jws:javax.jws-apijakarta.jws:jakarta.jws-api:1.1.1javax.annotation:javax.annotation-apijakarta.annotation:jakarta.annotation-api:1.3.5javax.activation:activationjakarta.activation:jakarta.activation-api:1.2.2javax.activation:javax.activation-apijakarta.activation:jakarta.activation-api:1.2.2The version element is updated only when it is explicitly declared on the
dependency. Versions managed via
<dependencyManagement>(absent at the usagesite) are left untouched.
Tests
JakartaEeApiMigrationStrategyTest(18 test cases) covers:--model,--all, default)jaxb-api,jaxws-api,javax.annotation-api,activation)<dependencyManagement>migration<dependencies>migrationRelates to / partially addresses #14163.
Note: this covers the case where projects explicitly declare the removed Java EE artifacts. Projects relying purely on
rt.jarwithout any POM declaration cannot be detected from the POM alone and are out of scope for this strategy.Hermes Agent (Claude Sonnet 4.5) on behalf of Guillaume Nodet