【问题标题】:Maven maven-exec-plugin multiple execution configurationsmaven maven-exec-plugin 多种执行配置
【发布时间】:2011-01-12 15:42:54
【问题描述】:

是否可以从命令行通过其 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

【问题讨论】:

  • 我无法让插件与 标记中的 一起工作。但是,它确实可以将其放在 标记之外。错误是“目标 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec 的参数 'executable' 丢失或无效”
  • 请注意,在上述“使用配置文件的替代解决方案”中,缺少&lt;plugins&gt; 标签。

标签: maven-2 maven


【解决方案1】:

我想如果你写执行目标:

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

它在 eclipse maven 插件中为我工作。

【讨论】:

    【解决方案2】:

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

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

    mvn exec:exec@foo
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:

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

        【讨论】:

        • 这并不完全正确。见my answer
        • 现在可以了。请参阅 slangois 的回答。
        猜你喜欢
        • 2012-03-13
        • 2014-04-23
        • 2019-02-13
        • 2012-10-25
        • 1970-01-01
        • 2014-07-04
        • 2017-05-06
        • 2012-11-13
        • 1970-01-01
        相关资源
        最近更新 更多