我的custom maven plugin有三个目标(mojos):
process-test-resources
已分配到默认阶段:generateStubs
package
已分配到默认阶段:generateTests
generate-test-sources
已分配到默认阶段:packaging
如何将这三个mojo绑定到default lifcycle phase,这样用户可以简单地使用插件而无需特殊配置和项目<plugin>
<groupId>io.codearte.accurest</groupId>
<artifactId>accurest-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
的任何更改?
用户只需添加:
<plugin>
<groupId>io.codearte.accurest</groupId>
<artifactId>accurest-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>convert</goal>
<goal>generateStubs</goal>
<goal>generateTests</goal>
</goals>
</execution>
</executions>
</plugin>
而不是
components.xml
我可以使用下面的ugly-fix
来实现这一点,但这需要一些丑陋的黑客(指定不存在阶段 - <component-set>
<components>
<component>
<role>org.apache.maven.lifecycle.Lifecycle</role>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<role-hint>accurest</role-hint>
<configuration>
<id>accurest</id>
<phases>
<phase>ugly-fix</phase> // plugin fail without this
</phases>
<default-phases>
<process-test-resources>
io.codearte.accurest:accurest-maven-plugin:${project.version}:convert
</process-test-resources>
<generate-test-sources>
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateTests
</generate-test-sources>
<package>
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateStubs
</package>
</default-phases>
</configuration>
</component>
</components>
</component-set>
)并且我不确定,如果此解决方案在所有情况下都有效。
for i in range(1, nodes):
for j in range(1, nodes):
for k in range(1, nodes):
这是对的吗?是更好的方法来进行这样的配置吗?
更多信息:
答案 0 :(得分:2)
您可以通过将ugly-fix
替换为<phases>
代码中的正确目标来实现这一目标:
<component-set>
<components>
<component>
<role>org.apache.maven.lifecycle.Lifecycle</role>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<role-hint>accurest</role-hint>
<configuration>
<id>accurest</id>
<phases>
<process-test-resources>
io.codearte.accurest:accurest-maven-plugin:${project.version}:convert
</process-test-resources>
<generate-test-sources>
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateTests
</generate-test-sources>
<package>
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateStubs
</package>
</phases>
<default-phases>
<process-test-resources>
io.codearte.accurest:accurest-maven-plugin:${project.version}:convert
</process-test-resources>
<generate-test-sources>
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateTests
</generate-test-sources>
<package>
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateStubs
</package>
</default-phases>
</configuration>
</component>
</components>
答案 1 :(得分:-1)
我认为您要查找的是player
注释的defaultPhase
属性,有关所有详细信息,请参阅https://maven.apache.org/components/plugin-tools/maven-plugin-tools-annotations/。