多模块项目 - 装配插件

发布于 2024-08-11 19:15:31 字数 222 浏览 4 评论 0原文

我正在使用 Maven 2.0.9 构建一个多模块项目。我已经在我的父 pom.xml 中定义了程序集插件。我可以使用

mvn install assembly:assembly

此命令构建我的程序集,运行测试两次,一次在安装阶段,另一次在组装阶段。我尝试了 assembly:single 但它引发了错误。非常感谢任何帮助我构建程序集而无需运行两次测试的帮助。

I am using Maven 2.0.9 to build a multi module project. I have defined the assembly plugin in my parent pom. I can get my assemblies built using

mvn install assembly:assembly

This command runs the tests twice, once during install phase and another during assembly. I tried assembly:single but it throws an error. Any help to get my assemblies built without running the tests twice is much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你在看孤独的风景 2024-08-18 19:15:31

调用程序集 mojo 将导致 Maven 使用正常生命周期构建项目,直到 package 阶段。所以,当你运行时:

mvn install assembly:assembly

你实际上是在告诉 Maven 运行一些事情两次,这包括测试阶段,正如你在 默认生命周期的文档

为了避免这种情况,请考虑仅运行:

mvn assembly:assembly

或将插件绑定到项目的构建生命周期:

<project>
  ...
  <build>
    ...
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          ...
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> <!-- this is used for inheritance merges -->
            <phase>package</phase> <!-- append to the packaging phase. -->
            <goals>
              <goal>single</goal> <!-- goals == mojos -->
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
</project>

Invoking the assembly mojo will cause Maven to build the project using the normal lifecycle, up to the package phase. So, when you run:

mvn install assembly:assembly

you are actually telling maven to run a few things twice and this includes the test phase as you can see in the documentation of the default lifecycle.

To avoid this, consider running only:

mvn assembly:assembly

Or bind the plugin on a project's build lifecycle:

<project>
  ...
  <build>
    ...
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          ...
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> <!-- this is used for inheritance merges -->
            <phase>package</phase> <!-- append to the packaging phase. -->
            <goals>
              <goal>single</goal> <!-- goals == mojos -->
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
</project>
五里雾 2024-08-18 19:15:31

我认为错误消息具有误导性,它表明您需要在与程序集插件调用本身相同的 maven 调用中运行“package”阶段。

您是否尝试过“mvn package assembly: assembly”或“mvn install assembly: assembly”?

适用于 Linux 、 JDK 1.6.0_16 、 Maven 2.2.1 、 Assembly Plugin 2.2-beta-4 。

I think the error message is misleading , it suggests you need to run the "package" phase within the SAME maven invocation as the assembly plugin's invocation itself.

Did you try "mvn package assembly:assembly" or "mvn install assembly:assembly" ?

Works for me under Linux , JDK 1.6.0_16 , Maven 2.2.1 , Assembly Plugin 2.2-beta-4.

原野 2024-08-18 19:15:31

您需要创建一个单独的项目用于在多模块项目中进行组装。
该单独的模块将只是组装 - 并且它将具有依赖项:应该添加到结果组装中的同级模块。

请阅读这篇文章:
http://www.sonatype.com/books /mvnref-book/reference/assemblies-sect-best-practices.html

You need to create a separate project for assembly in multi-module project.
That separate module will just assembly - and it will have dependencies: siblings that should be added to result assembly.

Please read this article:
http://www.sonatype.com/books/mvnref-book/reference/assemblies-sect-best-practices.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文