【问题标题】:Maven: same artifactID in shared plugin and profile build pluginMaven:共享插件和配置文件构建插件中的相同工件ID
【发布时间】:2013-09-12 08:46:44
【问题描述】:

我有一个 maven pom.xml,它将运行一组 ant 任务。有些任务仅适用于特定配置文件,有些任务适用于所有配置文件。这是我的

<build>
    <plugins>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                    <tasks>
                        <!-- Some of my common task -->
                    </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
<build>

<profiles>
    <profile>
        <id>developement</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <phase>test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                            <tasks>
                                <!-- Task specifics for profile -->
                            </tasks>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        <build>
    </profile>                      
</profiles>

我使用以下命令运行项目

mvn clean install -P developement

在构建此项目时,常见任务未运行。配置文件中的任务仅在运行。是不是因为我在共享插件和配置文件插件中使用了相同的 artifactID..?

我的环境:

Java 1.6 Maven 2.2.1 Windows 7 64 位

【问题讨论】:

    标签: java maven pom.xml maven-antrun-plugin


    【解决方案1】:

    显示的两个执行都缺少&lt;id&gt; 元素。因此,Maven 使用它的默认执行 ID,并且配置文件执行会覆盖常见的执行 ID。

    要解决此问题,请向两者添加 ID,如图所示,使用您选择的值。

       <!-- common configuration -->
            <executions>
                <execution>
                    <id>antrun-common</id>
                    <phase>test</phase>
        ....
       <!-- development profile configuration -->
            <executions>
                <execution>
                    <id>antrun-development</id>
                    <phase>test</phase>
    

    【讨论】:

    • 是的,你是对的。将 id 添加到执行中解决了我的问题。谢谢
    猜你喜欢
    • 1970-01-01
    • 2015-11-15
    • 1970-01-01
    • 2020-01-02
    • 1970-01-01
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 2017-04-27
    相关资源
    最近更新 更多