maven 上的 cxf-codegen-plugin 有一个奇怪的行为。
一些信息:
一个带有 3 个孩子的父 pom(称为 PARENT):SERVICE、CLIENT1、CLIENT2。
该服务从两个类开始生成由两个分类器描述的两个 wsdl。SERVICE pom.xml 是:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<executions>
<execution>
<id>generate-client-first</id>
<phase>process-classes</phase>
<configuration>
<classifier>first</classifier>
<className>com.CLASS1</className>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
<attachWsdl>true</attachWsdl>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
<execution>
<id>generate-client-second</id>
<phase>process-classes</phase>
<configuration>
<classifier>second</classifier>
<className>com.CLASS2</className>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
<attachWsdl>true</attachWsdl>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
</executions>
</plugin>
CLIENT1和2从SERVICE中产生的分类wsdl开始生成两个java客户端。因此 CLIENT1 pom.xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-sources-client1</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdlArtifact>
<groupId>com.something</groupId>
<artifactId>artifact</artifactId>
<version>${project.version}</version>
<classifier>first</classifier>
</wsdlArtifact>
</wsdlOption>
</wsdlOptions>
<defaultOptions>
<faultSerialVersionUID>FQCN</faultSerialVersionUID>
</defaultOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
CLIENT2 pom.xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-sources-client2</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdlArtifact>
<groupId>com.something</groupId>
<artifactId>artifact</artifactId>
<version>${project.version}</version>
<classifier>second</classifier>
</wsdlArtifact>
</wsdlOption>
</wsdlOptions>
<defaultOptions>
<faultSerialVersionUID>FQCN</faultSerialVersionUID>
</defaultOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
只运行 CLIENT2 pom ( mvn -U clean install ) 一切正常,只要在 PARENT pom 上运行目标mvn -U generate-sources 。
问题发生在运行:mvn -U clean install on parent pom,因为没有生成第二个客户端:实际上它总是“解析”第一个 wsdl:
[INFO] ------------------------------------------------------------------------
[INFO] Building client2 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ client2 ---
[INFO] Deleting /home/developer/workspace/PARENT/CLIENT2/target
[INFO]
[INFO] --- cxf-codegen-plugin:3.0.4:wsdl2java (generate-sources) @ client2 ---
[INFO] com.something:artifact:wsdl:first:1.0-SNAPSHOT resolved to /home/.../Class1.wsdl
[INFO] Resolved WSDL artifact to file /home/.../Class1.wsdl
问题与此不同,因为在那种情况下,单个构建中有 2 次执行。最后两个信息:1)我在本地遇到这个问题,而在 Jenkins 上一切正常。2) Maven 版本
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T18:29:23+01:00)
Maven home: /opt/develop/apache-maven/apache-maven-3.2.5
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_31/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-46-generic", arch: "amd64", family: "unix"
你能帮助我吗?
非常感谢!