32

是否可以通过命令行中的 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 执行:执行

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

对于好奇,这里有一个使用配置文件的替代解决方案:http: //www.mail-archive.com/user@mojo.codehaus.org/msg00151.html

4

4 回答 4

27

现在可以从 Maven 3.3.1 开始:请参阅改进MNG-5768Maven 3.3.1 发行说明

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

mvn exec:exec@foo
于 2015-07-10T10:21:21.180 回答
16

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

于 2010-02-03T17:53:04.707 回答
11

这里没有提到的是,从 Maven 2.2.0 开始,如果您执行任何插件的 id 为 "default-cli",那么当您从命令行运行该插件时,将使用该配置。您仅限于每个插件的一个默认执行,但这是一个开始。

于 2011-08-16T22:43:32.317 回答
0

我想如果你写执行目标:

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

它在 eclipse maven 插件中对我有用。

于 2011-08-16T22:12:50.407 回答