我正在尝试为大型多模块项目设置程序集插件。现在的目标是将我的所有工件放入一个目录中。这是我的描述符:
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>Install-Package</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<scope>runtime</scope>
<outputDirectory>dependencies</outputDirectory>
</dependencySet>
</dependencySets>
<moduleSets>
<moduleSet>
<binaries>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
目前,这会将我的所有工件复制到程序集目录中。到目前为止,一切都很好。问题是依赖项文件夹仅包含主 pom 文件中列出的依赖项。有没有办法将子模块的依赖项包含在程序集中,而不将它们全部列在根 pom 中? (如果子模块是单独构建的,那么将它们全部包含在根 pom 中会向子模块添加额外的未使用的依赖项)。
谢谢!
最佳答案
The problem is that the dependencies folder only includes dependencies that are listed in the main pom file.
是的,这就是“顶级”dependencySets
的作用。
Is there a way to include the dependencies of the sub modules in the assembly without listing them all in the root pom?
删除“顶部”dependencySets
并在 moduleSet
的 binaries
元素下声明一个:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>Install-Package</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<binaries>
<unpack>false</unpack>
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<scope>runtime</scope>
<outputDirectory>dependencies</outputDirectory>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
关于maven-2 - Maven 程序集插件 - 包含子模块的依赖关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3436359/