[英]How to execute a maven-plugin only with custom command?
I'm using xsdtojava
with cxf
maven` plugin:我将xsdtojava
与cxf
maven` 插件一起使用:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
...
</configuration>
<goals>
<goal>xsdtojava</goal>
</goals>
</execution>
</executions>
</plugin>
Question: I want to prevent executing this plugin on every mvn package
.问题:我想阻止在每个mvn package
上执行这个插件。 Instead, I only want to trigger the source generation manually.相反,我只想手动触发源生成。 But how?但是如何? I tried setting a custom phase or goal like <phase>generate-sources-now</phase>
or <goal>generate-sources-now</goal>
, but did does not work.我尝试设置自定义阶段或目标,例如<phase>generate-sources-now</phase>
或<goal>generate-sources-now</goal>
,但没有用。
Though I'd prefer a maven goal approach, the profile approach works as suggested:虽然我更喜欢 maven 目标方法,但配置文件方法按建议工作:
<profiles>
<profile>
<id>xsdtojava</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xsdtojava</goal>
</goals>
</execution>
</executions>
<configuration>
.....
Run with: mvn package -P xsdtojava
运行: mvn package -P xsdtojava
Plugins don't need to have executions.插件不需要执行。
Just configure you plugin as只需将您的插件配置为
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<configuration>
...
</configuration>
</plugin>
and call the goal in the usual :
notation ( cxf-xjc-plugin:goal
).并以通常的:
符号( cxf-xjc-plugin:goal
)调用cxf-xjc-plugin:goal
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.