默认情况下如何将Maven插件附加到阶段? [英] How to attach a maven plugin to a phase by default?
问题描述
我有一个应该在编译阶段运行的maven插件,因此在消耗我的插件的项目中,我必须执行以下操作:
I have a maven plugin that should run in the compile phase, so in the project that consumes my plugin, I have to do something like this:
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>my-goal</goal>
</goals>
</execution>
</executions>
如果用户已经包含我的插件,则我需要的是默认将my-goal
附加到编译阶段(理想情况下,不需要上述部分,只需声明插件即可).
What I need is to by default attach my-goal
to the compile phase if the user has included my plugin already (ideally the above part wouldn't be necessary, just the plugin declaration).
这可能吗?
推荐答案
放入@phase
医生说:
@phase <phaseName>
此注释指定此目标的默认阶段.如果将为此目标的执行添加到pom.xml中,但未指定阶段,则默认情况下,Maven会将目标绑定到此批注中指定的阶段.
This annotation specifies the default phase for this goal. If you add an execution for this goal to a pom.xml and do not specify the phase, Maven will bind the goal to the phase specified in this annotation by default.
如果这行不通,我认为有必要进行JIRA.
If this doesn't work, I guess a JIRA is warranted.
这篇关于默认情况下如何将Maven插件附加到阶段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!