I am currently testing to migrate a Java 8 application to Java 9 / Jigsaw, using jdk-9+149.
The project has been laid out in standard Maven directory layout, i.e. having src/main/java
, src/test/java
, etc.
As soon as I add the module-info.java
to src/main/java
, maven-compiler-plugin fails throwing a NullPointerException. This is because it expects to find a module-info for the test
directory, too. So, as far as I can see, the options are:
- keep test classes in a separate module, which means they can only access exported packages of the main module.
- move test classes into the main module, together with the sources, which means that the main module needs test dependencies.
Obviously, neither of those options seems to be desirable, so I assume there is a recommended way of testing Jigsaw modules in a Maven project. Unfornately, I could neither find recommendations nor examples.
EDIT: Adding some information that I didn't regard relevant when posting the question (sorry)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…