gnodet opened a new pull request, #14169: URL: https://github.com/apache/maven/pull/14169
## Summary Introduces `JakartaEeApiMigrationStrategy`, a new `mvnup` upgrade strategy that detects 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`, and `javax.jws`. Projects that declared these APIs as explicit Maven dependencies (e.g. `javax.xml.bind:jaxb-api`) will fail to compile on JDK 11+ unless they migrate to the standalone Jakarta EE equivalents. `mvnup` previously had no handling for these JEP 320 removed APIs. The existing `ToolchainPluginStrategy` only acts on JEP 182 retired source levels (≤7) and does not detect JEP 320-removed API usage even when `source=8` is declared. ## Fix The new `JakartaEeApiMigrationStrategy` (priority 16, runs alongside `ToolchainPluginStrategy`) scans all dependency sections in each POM file: - `<dependencies>` - `<dependencyManagement><dependencies>` - Profile `<dependencies>` and `<dependencyManagement>` - Plugin-level `<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 — making it source-compatible without requiring import changes: | Legacy (removed in JDK 11) | 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` | The version element is updated only when it is explicitly declared on the dependency. Versions managed via `<dependencyManagement>` (absent at the usage site) are left untouched. ## Tests `JakartaEeApiMigrationStrategyTest` (18 test cases) covers: - Applicability conditions (`--model`, `--all`, default) - Migration of each supported legacy artifact (`jaxb-api`, `jaxws-api`, `javax.annotation-api`, `activation`) - Version update when explicit; no version added when managed - `<dependencyManagement>` migration - Profile `<dependencies>` migration - No modification for non-matching POMs - Migration map completeness and validity Relates to / partially addresses #14163. **Note:** this covers the case where projects **explicitly declare** the removed Java EE artifacts. Projects relying purely on `rt.jar` without 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_ - [x] The code I'm contributing is licensed under the Apache License Version 2.0 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
