父模块中的程序集插件可以使用“moduleSets”聚合 pom 子级的二进制工件吗?

2023-12-08

在多模块项目中:

parent
  |- child1 (packaging:pom)

can parent生成的聚合工件child1?

经过两天多的测试和阅读文档后,我不确定这是否是由于设计、错误或我自己没有发现明显的原因而不可能实现的。

Using:

$mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /usr/share/maven-bin-3.0
Java version: 1.8.0_66, vendor: Oracle Corporation

Remarks:

  • 在以下示例中,将 child1 包装从pom to jar确实按预期工作!
  • 当前错误:

[错误] 无法在项目父项目上执行目标 org.apache.maven.plugins:maven- assembly-plugin:2.6:single (build-module): 无法创建程序集: 创建程序集归档包时出错: 您必须至少设置一个文件。 -> [帮助1]

  • 我附加了 child1 的 pom 的第二个版本,它也不起作用,其中我设置了 pom 打包模块不可用的所有 jar 打包绑定,也就是说,packaging=pom 或 Packaging=jar 的有效 pom 是相同的。这也行不通!

示例代码

(完整代码:https://github.com/gallardo/SO/tree/master/SO-33999969)

父pom:/pom.xml

...
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<name>parent</name>

<modules>
    <module>child1</module>
</modules>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <descriptors>
                    <descriptor>src/assembly/bundle.xml</descriptor>
                </descriptors>
                <attach>false</attach>
            </configuration>
            <executions>
                <execution>
                    <id>build-module</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>          
    </plugins>
</build>

child1 pom:child1/pom.xml

...
<artifactId>child1</artifactId>
<packaging>jar</packaging>
<name>child1</name>
<build>
    <plugins>
        <!-- Assembly -->
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <descriptors>
                    <descriptor>src/assembly/module.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>build-module</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>          
    </plugins>    
</build>

父程序集:/src/ assembly/bundle.xml

<assembly ... >
    <id>bundle</id>
    <formats>
        <format>dir</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>

    <moduleSets>
        <moduleSet>
            <useAllReactorProjects>false</useAllReactorProjects>
            <includeSubModules>true</includeSubModules>

            <binaries>
                <attachmentClassifier>module</attachmentClassifier>
                <includeDependencies>false</includeDependencies>
                <outputDirectory>my/output/directory</outputDirectory>
                <unpack>false</unpack>
            </binaries>
        </moduleSet>
    </moduleSets>
</assembly>

child1 程序集:src/ assembly/module.xml

<assembly ...>
    <id>module</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>src/main/java</directory>
            <outputDirectory>module-${project.artifactId}/java</outputDirectory>
            <filtered>false</filtered>
        </fileSet>
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory>module-${project.artifactId}/lib</outputDirectory>
            <includes>
                <include>${project.build.finalName}.jar</include>
            </includes>
        </fileSet>
    </fileSets>

</assembly>

child1“扩展”pom:/child1/pom.xml

(模拟jar包装)

...
<artifactId>child1</artifactId>
<packaging>jar</packaging>
<name>child1</name>
<build>
    <plugins>
        <!--
        These plugin settings are the plugin bindings that jar packaging
        configures for the jar packaging.
        If this project has packaging = pom, enabling them results in an
        effective pom identical to packaging = jar.
        -->            
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>default-testResources</id>
                    <phase>process-test-resources</phase>
                    <goals>
                        <goal>testResources</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.3.2</version>
            <executions>
                <execution>
                    <id>default-jar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <executions>
                <execution>
                    <id>default-compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-testCompile</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.10</version>
            <executions>
                <execution>
                    <id>default-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <!-- Assembly -->
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <descriptors>
                    <descriptor>src/assembly/module.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>build-module</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>          
    </plugins>    
</build>

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

父模块中的程序集插件可以使用“moduleSets”聚合 pom 子级的二进制工件吗? 的相关文章

随机推荐

  • 错误:参数类型 double/string 等不符合预期类型“AnyObject”

    我看了一些 iOS 编程教程 并对 AnyObject 有疑问 桥接不起作用 我有以下代码 import Foundation class CalculatorBrain private var accumulator 0 0 var in
  • 在 64 位进程中加载​​ 32 位 dll [重复]

    这个问题在这里已经有答案了 我希望我的 C 应用程序有条件地运行本机方法 有条件地选择运行 dll 的 x86 或 x64 版本 每当我尝试加载 32 位 dll 时 都会收到以下错误 Unhandled Exception System
  • 将 mat 文件转换为 pandas 数据框

    我想转换这个文件到 pandas 数据框 import pandas as pd import scipy io mat scipy io loadmat cardio mat cardio df pd DataFrame mat 我收到此
  • 继承int的类中的位运算

    我继承了 int 因为我想实现一个简单的按位运算接口 由于 int 的不可变性 我必须使用整数成员函数 例如int and class Bitset int def setitem self index value if value sel
  • Azure Function ServiceBusReceivedMessage ApplicatonProperties 为空

    我正在创建一个作为 ServiceBus 触发器的 Azure 函数 FunctionName RetryRack public async Task Run ServiceBusTrigger RackIntegration topic
  • 如何从 HashMap 中删除重复值

    我不知道如何最好地描述我的问题 但就是这样 我试图从中删除相同的名称 值 HashMap
  • 处理 Sql 服务器字符串连接中的 NULL

    我有以下 SQL 查询 select s comments s further comments from dbo samples s where id 1234 但是 如果 s comments 或 s further comments
  • 使用 python 从文本文件导入矩阵

    我有两个文本文件 其中写入了矩阵 不是 numpy 矩阵 所以它是一个列表列表 这些矩阵以字符串格式编写 因此文本文件如下所示 1 2 3 3 4 5 6 7 8 3 3 3 5 6 7 我想使用 python 从文本文件中读回这个矩阵 我
  • 从函数中调用按钮 OnClick

    我有一个 OnClick Button Click 按钮 我想从另一个函数调用 Button Click 但问题是我需要给出它 object sender EventArgs e 我应该为这些参数输入什么 有什么办法解决吗 你可以这样做 B
  • Karate - 获取一个以 char 开头并从 json 响应的最后出现的值

    我试图获取此 json 中存在的值 F20210518060000 name F20210518000000 timestamp 2021 05 18T00 00 00Z forecast from 2021 05 18T00 00 00Z
  • 与 pytest 并行运行单元测试? [复制]

    这个问题在这里已经有答案了 如何并行执行用 pytest 编写的单元测试 我可以选择哪些并行策略 为了并行运行 pytests 您需要安装pytest xdist 请参阅下面列出的不同并行策略 您可以使用其中任何一种 但是我可以打赌其中一种
  • 如何在 Xcode 6 或更高版本中创建类别?

    我想创建一个类别UIColor在我的应用程序中使用 Xcode 6 但问题是 在 Xcode 6 中没有 Objective C 类别文件模板 Xcode 6 中有创建类别的选项吗 他们没有忘记 他们只是在没有告诉任何人的情况下移动了它 C
  • Azure 容器实例在浏览器上不响应 DNS 名称

    我有本地监听端口 5000 的 docker 镜像 我已将映像部署到 Azure 容器注册表 然后我使用以下命令创建了 Azure 容器实例 az container create resource group myResourceGrou
  • 删除 NULL 指针安全吗?

    删除 NULL 指针安全吗 这是一种好的编码风格吗 delete无论如何都会执行检查 因此在您这边检查会增加开销并且看起来更难看 Avery好的做法是在之后将指针设置为 NULLdelete 有助于避免双重删除和其他类似的内存损坏问题 我也
  • 在 C 函数调用之前在内联汇编中推送额外的参数是否以任何方式(跨编译器、平台、libc 实现等)安全或可移植?

    我写了一个函数来漂亮地打印数独 当然这个模式可以通过一些循环生成 但我不想经历麻烦 所以这就是我想出的 前 5 个格式说明符只是 printf 的参数 本身被推入堆栈 并且在回车后将被覆盖 虽然 它可以在我的机器上运行 但我想知道这是否可以
  • 如何在不同的Qt线程中调用GUI元素?

    我有一个应用程序 其中线程 不是主线程 需要访问 GUI 的元素 发送单击操作 显示消息框等 我正在 python 和 Qt 中工作 也知道在非主线程中这是不可能的 有办法做到吗 我的意思是将我想要在线程中执行的操作发送到主线程 这是一个关
  • 如何在 Prolog 解释器中使用差异列表

    当我写下的时候这个问题在一个空列表上作为差异列表我想测试一下我对这些结构的了解 然而 当我尝试像比较不同符号这样简单的事情时 我似乎错了 而且我做了not了解差异列表的实际情况 L a b c d e d e L a b c false e
  • 为文本中的每个单词创建图像的建议

    我正在寻找一种方法来自动为文本文件中的每个单词创建图像渲染 我正在研究一种 简单 的方法来在不支持复杂脚本的计算机和手机上显示复杂的脚本 有没有一种简单的方法可以做这样的事情 文本将为高棉语 UTF 8 我已经尝试过 imagettftex
  • savefig 错误

    我计算机上的 Python 所有部分最近都是从 Enthought 学术包安装的 但使用 Pyscripter 来编辑和运行代码 我还处于学习曲线的早期阶段 因此很可能会忽略这里的一些明显的事情 当我尝试创建一个绘图并像这样保存它时 imp
  • 父模块中的程序集插件可以使用“moduleSets”聚合 pom 子级的二进制工件吗?

    在多模块项目中 parent child1 packaging pom can parent生成的聚合工件child1 经过两天多的测试和阅读文档后 我不确定这是否是由于设计 错误或我自己没有发现明显的原因而不可能实现的 Using mvn