Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jakartaee-platform-dev] Transitioning from Java EE to Jakarta EE and impact on Maven dependency management

Hello,

Sorry if this is not the best mailing list to send to. While reading the following article on transitioning from Java EE to Jakarta EE, I came across the following note on Maven dependency management when replacing a Java EE API with its Jakarta EE equivalent:

"For Maven, there are two totally different dependencies, and Maven will happily include both of them. This can happen, for instance, when a top-level dependency transitively brings in a Java EE dependency. Prior to the update to Jakarta, a transitively introduced javax.faces:javax.faces-api:2.2 would be overridden by, for example, a top-level javax.faces:javax.faces-api:2.3.

When that top-level dependency is changed to jakarta.faces:jakarta.faces-api:2.3.2, the 2.2 dependency will no longer be overridden and Maven will use them both, leading to all sorts of problems. If the transitive inclusion can’t be updated, this issue can typically be fixed by using exclusions..."

If I'm understanding correctly, this means if I'm migrating from e.g. javax.servlet-api:3.1.0 to jakarta.servlet-api:4.0.3, I would have to exclude javax.servlet-api from all transitive inclusions, otherwise two versions of the same API will be on the classpath. In a big project, there may be a lot of third parties that pull javax.servlet-api.

I've picked the above example on purpose: in my case I wanted to upgrade from Servlet 3 to 4 while migrating to Jakarta EE at the same time. But the need to add exclusions in other dependencies is holding me back from also moving to the jakarta groupId.

Ideally I would hope for a mechanism that tells Maven to treat jakarta.servlet-api:4.0.3 as a newer version of javax.servlet-api:3.1.0, as opposed to a completely different artifact. The closest thing I could find to theoretically achieve that was the Maven relocation mechanism. I wonder if anyone came across this issue and what they think about it.

Thanks,
Mahmoud


Back to the top