----- Mail original -----
> De: "Robert Scholte" <rfscho...@apache.org>
> À: "Sander Mak" <sander....@luminis.eu>, "Remi Forax" <fo...@univ-mlv.fr>
> Cc: "jigsaw-dev" <jigsaw-dev@openjdk.java.net>
> Envoyé: Vendredi 25 Novembre 2016 11:48:37
> Objet: Re: modules and tests

> On Thu, 24 Nov 2016 15:39:19 +0100, Remi Forax <fo...@univ-mlv.fr> wrote:
> 
>> setting command line arguments or using a build tool to fiddle them for
>> you is exactly what we do not want here! We want fidelity between the
>> compile time configuration and the runtime configuration. Having to play
>> with -Xpatch at runtime is conceptually exactly like setting the
>> classpath. I don't want to explain to the Java devs that we have
>> fidelity between compile-time and runtime on source code but not on test
>> code.
> 
> I agree on this one. I've been thinking about this a lot and I'm wondering
> if this is a Java issue or test-tool issue.
> What I see with JUnit is that everything is added to the (class)path. I've
> been wondering if having separate arguments for the main classes and test
> classes would make it possible to prevent the patch argument while
> chaining classloaders.
> e.g. java -jar junit.jar -DmainPath=<arg> -DtestPath=<arg> ...<moreArgs>
> 
> in Maven terms: mainPath will contain all compile-dependencies, testPath
> will contain all test-dependencies WITHOUT the compile-dependencies.
> 
> However, is this enough to support split packages?

Technically, having a source folder and a test folder is not a split packages 
case, because everything goes in the same module at the end.
 
What i've done is creating two artifacts, one modular jar with only the source 
code and one modular jar that contains the source code and the test code, they 
are stored in two different folders, target/src/artifact and 
target/test/artifact. Both jars do not have the samefile name (test modular jar 
are prefixed by test to avoid to use them in production) but both define the 
same module name.
The requires directives all the requires directive of the source modular jar 
merged with the one of the test modular jar (like JUnit). All dependencies 
(compîle-dependencies and test-dependencies) are stored in the same folder, 
because the VM pick the right modules using the requires directives.
At runtime, my test runner creates a new layer, with 3 module finders, the 
first one only find the test module i want to test (so i do the test of each 
module in isolation and not all test modules altogether), the second one 
contains the modular jars from the sources and the last one resolve all 
external dependencies.

> 
> Robert

Rémi

Reply via email to