我使用Maven程序集插件为我的多模块项目创建一个程序集.从这个多模块项目构建了两个独立的应用程序,每个应用程序都有一组独立的依赖项.我创建了一个自定义程序集描述符,它使用模块构建及其各自的依赖项组装两个目录(对于每个应用程序).它做的一切都很好,但有一点 - 它将两个模块的依赖关系放到彼此的程序集中.
以下是我的项目的简化版本,具有完全相同的行为.
考虑一个由两个模块和一个组装模块组成的项目:
APP
module1
module2
assembly
Run Code Online (Sandbox Code Playgroud)
我已经添加了纯粹用于演示的依赖项:
com.test.app:module1:jar:1.0
\- commons-cli:commons-cli:jar:1.2:compile
com.test.app:module2:jar:1.0
\- commons-daemon:commons-daemon:jar:1.0.8:compile
Run Code Online (Sandbox Code Playgroud)
这是父POM:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>app</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
<module>module2</module>
<module>assembly</module>
</modules>
</project>
Run Code Online (Sandbox Code Playgroud)
module1 POM:
<project>
<parent>
<groupId>com.test</groupId>
<artifactId>app</artifactId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.app</groupId>
<artifactId>module1</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
module2 POM:
<project>
<parent>
<groupId>com.test</groupId>
<artifactId>app</artifactId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.app</groupId>
<artifactId>module2</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>commons-daemon</groupId>
<artifactId>commons-daemon</artifactId>
<version>1.0.8</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
装配POM:
<project>
<parent>
<groupId>com.test</groupId>
<artifactId>app</artifactId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.app</groupId> …Run Code Online (Sandbox Code Playgroud) dependency-management maven maven-assembly-plugin multi-module