【发布时间】:2023-03-05 06:45:01
【问题描述】:
我正在寻找一种在安装时不执行插件的方法。更具体地说,我的场景如下:
- 我正在使用 org.apache.cxf:cxf-codegen-plugin 来生成源代码。
- 每次我清理+安装源都会生成
- 我只希望在我明确请求时生成源代码。
我们将不胜感激任何和所有的帮助!
【问题讨论】:
标签: maven-2 jax-ws cxf wsdl2java
我正在寻找一种在安装时不执行插件的方法。更具体地说,我的场景如下:
我们将不胜感激任何和所有的帮助!
【问题讨论】:
标签: maven-2 jax-ws cxf wsdl2java
我只希望在我明确请求时生成源代码。
最好的选择是在配置文件中添加插件声明并显式激活此配置文件:
<project>
...
<profiles>
<profile>
<id>codegen</id>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/myService.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
当您希望代码生成发生时,运行以下命令:
mvn clean install -Pcodegen
【讨论】:
我相信你想在你的 POM 中为 cxf 的 plugin 元素添加一个 executions 元素。您应该能够将生成目标绑定到您喜欢的阶段。见:http://maven.apache.org/pom.html#Plugins
【讨论】: