Hello Stephen
Just a very quick reply, as I have to go. But I will try to provide more
details tomorrow.
I agree with the problem that you describe, and a massive amount of work
is ongoing for improving Maven support of JPMS, including whitebox
testing. The Maven compiler plugin has already been fully rewritten in a
separated repository [1] but not yet merged on the Maven repository. One
of the change is to get ride of Plexus compiler and uses directly the
javax.tools compiler API, in part because this API provides specialized
methods for JPMS.
While having two module-info is still supported (I think, it would need
extensive testing), I'm more inclined in having only one module-info in
the main source code and letting the compiler and JUnit generates
automatically the --patch-modules, --add-exports, --add-reads, etc.
options. We will try to do that in documented and predictable way, as
one goal of this rewrite is to avoid as much "black magic" as we can.
This work will require Maven 4. Some changes are in progress in support
for that. One of the change is that Maven 4 gives full control to the
developer about whether to put a dependency on the class-path or
module-path. This part is already in Maven core, but not yet honored by
plugins, except the compiler prototype. Another work in progress right
now is proposing to change the way that we declare the sources in Maven,
for supporting both module source hierarchy and (as a side effect) more
easily multi-release projects.
I will try to give more details tomorrow. If you were available for
testing and feedback, that would be greatly appreciated. However at this
time, only the compiler plugin has been rewritten. We will also need to
update Surefire, but this work hasn't started yet.
Martin
[1]https://github.com/Geomatys/maven-compiler-plugin/commits/beta2