Maven Multiple Module Management

Usage

  1. Parent pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<artifactId>library</artifactId>
<groupId>com.anda.library</groupId>
<version>1.0.0</version>
<packaging>pom</packaging>

<modules>
<module>common</module>
<module>network</module>
</modules>


<!-- Gloable Dependencies -->
<dependencies>
<!-- declare dependencies -->
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<!-- declare dependencies version -->
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.2</version>
</dependency>
</dependencies>
</dependencyManagement>
  1. Network Module pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
<groupId>com.anda.library.network</groupId>
<version>1.0.0</version>
<artifactId>network</artifactId>

<!-- Network Module dependent on Common Module -->
<dependencies>
<dependency>
<groupId>com.anda.library.common</groupId>
<artifactId>common</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
  1. Common Module pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<groupId>com.anda.library.common</groupId>
<version>1.0.0</version>
<artifactId>common</artifactId>

<dependencies>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
</dependencies>