Maven插件在构建期间执行多次 [英] Maven plugin executes multiple times during build

查看:106
本文介绍了Maven插件在构建期间执行多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Maven项目,其中有多个重叠的配置文件.我想在每个构建的开始显示活动配置文件.因此,我将以下内容放入pom.xml <build>部分:

I have a Maven project with multiple overlapping profiles. I want to display the active profiles at the beginning of every build. So I put the following into the pom.xml <build> section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-help-plugin</artifactId>
    <version>2.1.1</version>
    <executions>
        <execution>
            <id>display-active-profiles-at-start-of-build</id>
            <phase>validate</phase>
            <goals>
                <goal>active-profiles</goal>
            </goals>
        </execution>
    </executions>
</plugin>

问题在于该插件在构建过程中执行了多次:

The problem is that the plugin executes multiple times during the build:

  1. 在构建开始时(在validate阶段).
  2. 执行jar:jar时.
  3. source:jar之后/在pre-integration-test(?)期间,当启动Jetty时.
  1. At the beginning of the build (during the validate phase).
  2. When jar:jar executes.
  3. After source:jar / during pre-integration-test (?), when Jetty is being started.

指定<phase>initialize</phase>时的结果相似.有没有办法让它仅在构建开始时运行?

Similar results when specifying <phase>initialize</phase>. Is there a way to get this to only run at the beginning of the build?

推荐答案

执行多次的原因是,您的一个插件正在执行另一个生命周期作为其mojo的一部分.

The reason it executes several times, is because one of your plugins is executing another lifecycle as part of its mojo.

source:jar确实可以做到,如其文档中所指定.

在执行生命周期阶段generate-sources之前执行 自己执行.

Invokes the execution of the lifecycle phase generate-sources prior to executing itself.

jar:jar通常不会,但是可能是您有另一个插件可以释放另一个生命周期.

jar:jar usually does not, but it may be that you have another plugin that spins off another lifecycle.

在生成源jar的情况下,通常不需要其他生命周期,并且插件作者通过实现

In case of generation of source jar, you generally don't need another lifecycle, and plugin authors recognized this by implementing jar-no-fork mojo.

您可以按照以下说明的步骤将其替换为默认的jar mojo-> http://maven.apache.org/plugins/maven-source-plugin/usage.html

You may substitute it for default jar mojo, by following steps described here -> http://maven.apache.org/plugins/maven-source-plugin/usage.html

这篇关于Maven插件在构建期间执行多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆