I am trying to make my project ready for Java 9 and I am running into problems with split packages (artifacts sharing the same package).
My application depends on at least two third-party legacy artifacts (that are built with Java <9). When I run Maven with Java 9, I get:
[ERROR] module myapp reads package P from both A and B
Which is correct, since the package P exists in A.jar and B.jar, but without overlapping classes. I understand that this is a problem for Java 9 and I studied suggested solutions in https://blog.codefx.org/java/java-9-migration-guide/#fixes-2 . To summarize it is either "Fix your code" (not possible, since third-party JAR) or "Run with command line options" (Where the most interesting may be --patch-module <package>=<path-to-jar>
).
There was another idea here, which said
wrap one of the 3rd party modules (or both) in a simple module, which does nothing but explicitly exports only the package(s) that are actually needed by your module.
But how can I achieve this in Maven (3.5.0), where all I currently have is a <dependency>
and the maven-compiler-plugin:3.7.0 - and I don't want to statically repackage third party JARs?
Any hint or pointer to an example would be welcome.