Maven maven-exec-plugin多个执行配置

时间:2010-02-03 14:37:19

标签: maven-2 maven

是否可以通过命令行中的id调用maven-exec-plugin(或任何其他插件)执行?

假设我的pom.xml文件如下所示:

<project>
[...]
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>foo</id>
            <goals>
                <goal>exec</goal>
            </goals>
            <phase></phase>
            <configuration>
                <executable>echo</executable>
                <arguments>
                    <argument>foo</argument>
                </arguments>
            </configuration>
        </execution>
        <execution>
            <id>bar</id>
            <goals>
                <goal>exec</goal>
            </goals>
            <phase></phase>
            <configuration>
                <executable>echo</executable>
                <arguments>
                    <argument>bar</argument>
                </arguments>
                </configuration>
            </execution>
        </executions>
    </plugin>
[...]
</project>

现在可以打电话了

  

mvn exec:exec

有一些额外的魔法来运行执行“foo”?

对于好奇的人,可以使用此处提供的配置文件替代解决方案: http://www.mail-archive.com/user@mojo.codehaus.org/msg00151.html

4 个答案:

答案 0 :(得分:23)

现在可以从Maven 3.3.1开始:见改进MNG-5768Maven 3.3.1 release notes

您可以使用以下语法调用特定的执行配置:

onBindViewHolder

答案 1 :(得分:16)

不,这是不可能的。执行是为了绑定到生命周期(即它们不是设计为在命令行上调用)。因此,您必须使用您提供的链接中描述的配置文件技巧。

答案 2 :(得分:11)

这里没有提到,从Maven 2.2.0开始,如果你give an execution of any plugin the id "default-cli",那么当你从命令行运行该插件时,就会使用该配置。你只限于每个插件的一个默认执行,但它是一个开始。

答案 3 :(得分:0)

我想如果你写下执行目标:

org.codehaus.mojo:exec-maven-plugin:¿Version?:exec

它在eclipse maven插件中适用于我。

相关问题