maven-2 - Maven 程序集插件 - 包含子模块的依赖关系?

标签 maven-2

我正在尝试为大型多模块项目设置程序集插件。现在的目标是将我的所有工件放入一个目录中。这是我的描述符:

    <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 并在 moduleSetbinaries 元素下声明一个:

<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/

相关文章:

java - 当 JUnit 失败时如何停止 Maven?

android - 如何在 Android 上测试库?

java - 为什么嵌入式 OpenEJB 无法部署我的应用程序?

java - 在 Maven2 Web 应用程序中使用 JSBuilder2.jar

java - 完成我的第一个 Spring MVC 应用程序 - 老板想看我的单元测试 - 我从哪里开始?

maven-2 - Maven 属性重载

maven-2 - Maven2 : How to stage JXR plugin result when using mvn site?

performance - 为什么 hudson "mvn clean install"构建的时间比命令行上的构建时间长 3-6 倍?

具有不同配置文件的 Maven 配置文件

Maven 类路径错误多个 SLF4J 绑定(bind)