module resource loading - opens {package} when {package} only holds resources
Alan Bateman
Alan.Bateman at oracle.com
Tue Sep 21 07:44:58 UTC 2021
On 20/09/2021 23:15, Rob Bygrave wrote:
> /:/
>
> In case it's interesting, one thing that I hit when migrating to
> module-info was that a number of the modules are only used in maven
> test scope - as such they don't get a /requires/ clause in
> src/main/java/module-info. Currently when running tests via maven,
> surefire, junit5 there is an unnamed module created for testing
> purposes that is patched and adds the main module. Currently these
> maven test scope only modules are getting treated as unnamed when
> running tests and so at this point can't be referenced in an /exports
> to/ clause of another module. The net result is that I have some
> /exports/ clauses that ideally would be /exports to /but can't at this
> stage. There might be a detail I am missing but this is ok and
> probably isn't a common case.
>
I don't think I understand the issue. The compiler plugin should compile
the tests "as if" they are part of the module. When the tests execute
then the Surefire plugin should be do the same as compile-time and patch
the module to include the test classes. Under the covers I would expect
both plugins to use --patch-module, --add-reads junit5, and maybe
--add-exports to export packages to junit5. It sounds like there may be
a mismatch between compile-time and run-time but I can't be sure without
seeing more.
-Alan
More information about the jigsaw-dev
mailing list