On Tue, 24 Sept 2024 at 16:13, Martin Desruisseaux
<martin.desruisse...@geomatys.com> wrote:
> If you are willing to test the development regarding JPMS, there is the
> steps:
>
>   * Download Maven 4.0.0-beta4
>   * Use Maven 4 for building the master branch of
>     https://github.com/apache/maven-plugin-tools
>   * Use Maven 4 for building
>     https://github.com/apache/maven-plugin-testing/pull/44. Use "mvn
>     install -Denforcer.skip".
>   * Use Maven 4 for building
>     https://github.com/Geomatys/maven-compiler-plugin/tree/beta2. Use
>     "mvn install -Denforcer.skip".
>   * Set the compiler version to "4.0.0-beta-2-SNAPSHOT" in your project.

See https://github.com/JodaOrg/joda-money/tree/maventest

At present, the compile phase is asked to compile module-info.java,
but the target/classes directory does not contain module-info.class.
I've no idea where it is going I'm afraid.

>     (note: I was wrong
>     yesterday, the current prototype does not allowed anymore to have
>     module-info in both main and test. The latter is replaced by
>     automatically generated compiler options).

I don't believe this is the right direction to go. The command line
flags are difficult to understand, and connect to the matching meaning
in module-info.java. By contrast, simply specifying a testing
module-info.java directly expresses what needs to be expressed.
Furthermore, IntelliJ already supports BlackBox testing in
src/test/java, plus it is the recommended approach on the Maven
website, so I don't think it is viable to remove that.

As a separate point, it is very hard to know what the plugin is doing.
AFAIK, the only approach to finding out what is going on is to use -X
which produces far too many logs.


>   * In project dependencies, add <type>modular-jar</type> for forcing
>     the compiler to put the JAR dependency on the module path instead of
>     trying to guess.
>   * Conversely, use <type>classpath-jar</type> for forcing the compiler
>     to put the JAR dependency on the class-path.

I can't see many people wanting to set these. They are also
restricting. (I believe use of these setting would mean that I cannot
be used to run the same tests three times, as I am currently doing
with Maven 3)


> Regarding white-box testing in a modular project:
>   * The plugin uses the --patch-module option for specifying the
>     directories of test classes to the Java compiler.
>   * The plugin adds the following options for test dependencies that are
>     not present in the main dependencies (typically JUnit):
>       o --add-modules and --add-reads for compile-time dependencies.
>       o --add-modules only for runtime-time dependencies (typically
>         services to be discovered with java.util.ServiceLoader).
>       o --add-reads ALL-UNNAMED if at least one compile-time test
>         dependency is not modular.

You also need to ensure that
- src/main/resources and src/test/resources are correctly patched
- the module-info.java `requires static` directive is correctly followed.

Stephen

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to