Example example_maven_test-whitebox
Part of the full Java 9 Jigsaw modules example suite.
|
Authors
Originally written by Martin Lehmann, Kristine Schaal and RĂ¼diger Grammes (cf. original repository). Migrated for Java Modules support documentation of Apache MavenTM in the course of the Maven Support & Care program by Gerd Aschemann (and other team members) as forked repository. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original. |
What is this example about?
Modules in this example
-
modmain, and org.apache.commons.lang3 from a maven dependency
-
modmain has a Main class which is started in
run.sh
Example shows …
-
Compilation, test compilation and execution with Maven
-
Whitebox test via patching the module
modmainwith classes in `src/test/`java
The Maven compile plugin and the surefire plugin now use the patch options to compile and run test classes as part of the module to be tested.
For an example using the patch options explicitly, see here.
It finds out that the patch options are needed because there is no module-info.java in src/main/test.
It then parses the module name from the module-info.java in src/main/java.
Note: No JavaDoc generation for this example
Setup
You might want to edit the Maven settings file mvn_settings.xml according to your needs (proxies, local repository path etc.)
The file provided here is just a copy of the original file from Maven 3.5.2 distribution.
Maven plugins
-
A maven-compiler-plugin (version >= 3.6.2) is needed (because we need the new patch options)
-
Note that the maven-compiler-plugin (version 3.6.2) currently has a bug ("syntax error") when there are comments in the
module-info.java -
The current surefire-plugin does not yet support modules. It runs tests in classpath mode.
Output and Testing
This example does not use golden master testing because Maven output includes timestamps, absolute file paths, and version information that varies between runs. See the golden master testing section in the main README for more information.