Example example_requires_exports_requires-transitive_exports-to

Part of the full Java 9 Jigsaw modules example suite.

Authors

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

  • moda, modb, modc, modfacade, modmain, modmainbehindfacade

  • modmain has a Main class which is started in run.sh

Module Dependency Graph, created with DepVis

without facade modules

Example’s Module Dependency Graph

withfacade modules

Example’s Module Dependency Graph

Example shows …​

  • Usage of requires

  • Usage of exports

  • Usage of requires transitive

  • Usage of exports to

Output

This example uses golden master testing to ensure output consistency. The expected output is compared with actual output using verify.sh.

Expected Output

A1: from A1, from B
from A1: getMyC()=pkgc.C, id=ID_A1_19
from A1: getMyC()=pkgc.C, id=ID_A1_19
A2: from A2 (plus: from InternalA)
A3: from A3

A1: from A1, from B
from A1: getMyC()=pkgc.C, id=ID_A1_19
from A1: getMyC()=pkgc.C, id=ID_A1_19

Actual Output

A1: from A1, from B
from A1: getMyC()=pkgc.C, id=ID_A1_19
from A1: getMyC()=pkgc.C, id=ID_A1_19
A2: from A2 (plus: from InternalA)
A3: from A3

A1: from A1, from B
from A1: getMyC()=pkgc.C, id=ID_A1_19
from A1: getMyC()=pkgc.C, id=ID_A1_19

Maven 4 Output

A1: from A1, from B
from A1: getMyC()=pkgc.C, id=ID_A1_19
from A1: getMyC()=pkgc.C, id=ID_A1_19
A2: from A2 (plus: from InternalA)
A3: from A3

A1: from A1, from B
from A1: getMyC()=pkgc.C, id=ID_A1_19
from A1: getMyC()=pkgc.C, id=ID_A1_19

Maven 4 Migration

This example was migrated to Maven 4 using the standard approach documented in the central Maven 4 Migration guide.

The source files follow the standard Module Source Hierarchy setup. The runtime execution in m4/run.sh was aligned with the original run.sh to execute both main classes sequentially, ensuring compatibility with the expected output.