在maven插件执行中禁用目标 [英] Disabling goals in a maven plugin execution
问题描述
我有一个设置,其中我的大多数项目都需要为编译和testCompile目标运行xtend插件。我在pluginManagement部分描述它:
I have a setup where most of my projects require the xtend plugin to be run both for the compile and testCompile goals. I describe it in a pluginManagement section:
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
<version>2.5.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
现在,有些项目不需要一个目标或另一个目标。我尝试了继承的标签,随机属性玩,但没有工作。如何覆盖执行以仅包含所需目标?
Now, there are some projects that don't need one goal or the other. I've tried the inherited tag, played around with random attributes but none worked. How can I override the execution to contain only the desired goal?
更新:故事的结论是无法禁用个人目标。可以管理的最小范围是执行
。
UPDATE: The conclusion of the story is that individial goals cannot be disabled. The smallest scope that can be managed is the execution
.
推荐答案
一般来说,你只能通过一个技巧禁用执行:
Generally, you can only disables executions with a trick:
将执行阶段设置为不存在阶段( dont-execute
)。但请注意,您必须使用两个不同的执行ID才能同时关闭两个目标:
Set the executions phase to non existant phase (dont-execute
). Note however, that you have to use two different execution ids to allow both goals to be individually turned off:
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
<version>2.5.3</version>
<executions>
<execution>
<id>xtend-compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>xtend-testCompile</id>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
子模块:
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
<version>2.5.3</version>
<executions>
<execution>
<id>xtend-testCompile</id>
<phase>dont-execute</phase>
</execution>
</executions>
</plugin>
在您的具体情况下,您当然也可以使用 skipXtend
每次执行中的配置属性都不会跳过执行,但只会阻止插件执行任何操作:
In your specific case, you could, of course, also use the skipXtend
configuration property in each execution to not skip the execution, but only prevent the plugin from doing anything:
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
<version>2.5.3</version>
<executions>
<execution>
<id>xtend-testCompile</id>
<configuration>
<skipXtend>xtend-testCompile</skipXtend>
</configuration>
</execution>
</executions>
</plugin>
这篇关于在maven插件执行中禁用目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!