Maven maven-exec-plugin多个执行配置 [英] Maven maven-exec-plugin multiple execution configurations
问题描述
是否可以从命令行通过其ID调用maven-exec-plugin(或任何其他插件)执行?
Is it possible to invoke a maven-exec-plugin (or any other plugin's) execution by its id from the command line?
假设我的pom.xml文件如下所示:
Let's say my pom.xml file looks like this:
<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
mvn exec:exec
具有一些附加的魔术来执行"foo"执行吗?
with some added magic to run execution "foo"?
出于好奇,这里有一个使用配置文件的替代解决方案: http://www.mail-archive.com/user@mojo .codehaus.org/msg00151.html
For the curious there is an alternative solution using profiles available here: http://www.mail-archive.com/user@mojo.codehaus.org/msg00151.html
推荐答案
否,这是不可能的.执行是用于绑定到生命周期的(即,它们不是设计为在命令行上调用的).因此,您必须使用提供的链接中描述的配置文件技巧.
No, it's not possible. Executions are for binding to the lifecycle (i.e. they are not designed to be invoked on the command line). So you'll have to use the profile trick described in the link that you provided.
这篇关于Maven maven-exec-plugin多个执行配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!