当我为目标配置了多个配置时,如何使用Maven插件中的特定配置运行特定目标
请参见下面pom.xml中的插件配置.
See plugin config from pom.xml below.
我可以做到:
mvn myplugin:myGoal
哪个运行myGoal(我猜这两个执行程序),但我希望能够独立选择第一个或第二个执行程序.
Which runs myGoal (both executions I suppose) but I want to be able to choose either the first or the second executions independently.
我知道我可以在执行元素中添加一个ID,但是如何在命令行上引用该ID.我想做一些能实现此想象的命令的事情:
I know I can add an id to the execution element, but how do I refer to that id on the command line. I'd like to get to something which does what this imagined command does:
mvn myplugin:myGoal --executionId=1
这是可能的,还是我走错路了?
Is this possible, or am I going about this the wrong way?
<plugin>
<groupId>org.myplugin</groupId>
<artifactId>myplugin-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>myGoal</goal>
</goals>
<configuration>
<myParam>cats</myParam>
</configuration>
</execution>
<execution>
<goals>
<goal>myGoal</goal>
</goals>
<configuration>
<myParam>dogs</myParam>
</configuration>
</execution>
</executions>
</plugin>
我可以做
mvn myplugin:myGoalWhich
运行myGoal(我猜这两个执行程序)
I can do
mvn myplugin:myGoalWhich
runs myGoal (both executions I suppose)
都不存在(假设它们具有唯一的id
).执行被绑定到一个阶段,您需要运行给定的阶段来触发它们.
None of them (assuming they had unique id
). Executions are bound to a phase, you need to run the given phase to trigger them.
我知道我可以在执行元素中添加一个ID,但是如何在命令行上引用该ID.
I know I can add an id to the execution element, but how do I refer to that id on the command line.
不支持.在CLI上调用的插件可能是使用特殊的default-cli
executionId
在POM中定义非全局配置,如下所示:
Not supported. What is possible for plugins invoked on the CLI is to define a non global configuration in the POM using the special default-cli
executionId
, like this:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
<descriptorRef>project</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
这是可能的,还是我走错路了?
Is this possible, or am I going about this the wrong way?
否,不可能.可以在命令行上传递参数,也可以使用配置文件(带有或不带有上述默认执行).
No, not possible. Either pass the parameters on the command line or use profiles (with or without the above default execution).
- Default Plugin Execution IDs
- http://jira.codehaus.org/browse/MNG-3203
- http://jira.codehaus.org/browse/MNG-3401