Hello Siddharth
I do not have a precise answer to your question, but below is a few notes.
Le 2023-10-12 à 23 h 07, Siddharth Jain a écrit :
I have observed the maven-compiler-plugin behaves differently for test
vs. main compilation.
Which approach did you choose for the tests? One approach is to
duplicate the module-info.java file in the test directory [1], but this
is not the only way.
I see during the test-compile phase the plugin is putting all the
dependencies on the module-path whereas during the main compilation it
only puts those dependencies on the module-path that are declared in
module-info.java; the rest are on the classpath (which is the correct
behavior).
Indeed this is the correct behaviour in a lot of cases, but not always.
Sometime we really want non-modular dependencies to nevertheless be on
the module-path. So we need a way to give control to developers about
which dependencies to put on the module-path versus class-path. This is
the topic of JIRA issue MNG-7855 [2]. We had a little bit of discussion
about that during the "Community Over Code" meeting (formerly
"ApacheCon") that just finished two days ago. A proposal was to create a
wiki page for designing a short-term fix.
Is this a known issue? Is there any fix? Without it, how can we use JPMS?
I think that MNG-7855 is a blocker issue. Without a fix, doing gradual
migration to JPMS with Maven (i.e. being in a situation where we have a
mix of JPMS and non-JPMS modules) is difficult except in some special cases.
Martin
[1]https://maven.apache.org/surefire/maven-surefire-plugin/examples/jpms.html
[2]https://issues.apache.org/jira/browse/MNG-7855