Mavenで次のような複数モジュール構成のプロジェクトをビルドする例です。
.
├── child1
│ ├── child1.iml
│ ├── pom.xml
│ ├── src
│ └── target
├── child2
│ ├── child2.iml
│ ├── pom.xml
│ ├── src
│ └── target
└── pom.xml
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>root</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>Multi Chapter Root Project</name>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
</project>
child2/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>root</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>child2</artifactId>
<packaging>jar</packaging>
<name>Multi Chapter Child2 API</name>
</project>
child1/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>root</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>child1</artifactId>
<packaging>jar</packaging>
<name>Multi Chapter Child1 API</name>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>child2</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
プロジェクトを指定して実行する
$ mvn --projects child1 clean install exec:java -Dexec.mainClass=com.example.child1.Main