We use maven
and have artifacts that in turn depend on other internal artifacts. I am in the process of migrating to java-9, and intend to migrate everything to Java 9 first without modularizing the code (i.e. in the unnamed module).
The problem I run into is that we depend on java.xml.bind
, which is now not included in the default modules. Is there a "correct" way to express this dependency on java.xml.bind
with Maven?
The Module System speaks of the way the unnamed modules as in your case of loading the application from classpath constructs the module graph. Further, from the documentation itself:-
Similar issue was faced in jetty.project where a thread from jdk mailing list discussed over the same and the fix was to use:
which provided them access to all Java SE modules and in your case shall simply be:
To use this in maven, you can embed the same to the
maven-compiler-plugin
usingas suggested by ZhekaKozlov here.
An important point to note is that marking deprecation of an API also means you might probably want to get away from using it. To adapt to this way you can probably start consuming the dependency on
jaxb-api:2.3.0
which can now be loaded as a module and can be executed from the classpath as well. The change you need to make is to add the following to your dependencies list:Update:- Eventually, with Java-10 already out and JDK/11 up next, one should ideally follow the link to JEP 320: Remove the Java EE and CORBA Modules and further replace such dependencies with their standalone libraries instead.