2012-10-12 71 views
2

我使用CXF maven插件來從WSDLCXF忽略sourceRoot配置參數

<plugin> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-codegen-plugin</artifactId> 
    <version>${cxf-codegen-plugin.version}</version> 
    <executions> 
     <execution> 
      <id>wsdl2java</id> 
      <configuration> 
       <sourceRoot>src/main/generated</sourceRoot> 
       <wsdlOptions> 
        <wsdlOption> 
         <wsdl>src/main/resources/wsdl/contentprovidercallback.wsdl</wsdl> 
         <extraargs> 
          <extraarg>-verbose</extraarg> 
          <extraarg>-frontend</extraarg> 
          <extraarg>jaxws21</extraarg> 
          <extraarg>-b</extraarg> 
          <extraarg>src/main/resources/wsdl/jaxws-contentprovidercallback.xml</extraarg> 
          <extraarg>-d</extraarg> 
          <extraarg>src/main/generated</extraarg> 
          <extraarg>-faultSerialVersionUID</extraarg> 
          <extraarg>FQCN</extraarg> 
          <extraarg>-xjc-Xts</extraarg> 
          <extraarg>-xjc-XhashCode</extraarg> 
          <extraarg>-xjc-Xequals</extraarg> 
         </extraargs> 
        </wsdlOption> 
       </wsdlOptions> 
      </configuration> 
      <goals> 
       <goal>wsdl2java</goal> 
      </goals> 
     </execution> 
    </executions> 
    <dependencies> 
     <dependency> 
      <groupId>org.codehaus.woodstox</groupId> 
      <artifactId>stax2-api</artifactId> 
      <version>${stax2.api.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.cxf.xjcplugins</groupId> 
      <artifactId>cxf-xjc-ts</artifactId> 
      <version>${cxf.xjc.ts.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.jvnet.jaxb2_commons</groupId> 
      <artifactId>jaxb2-basics</artifactId> 
      <version>${jaxb2.basics.version}</version> 
     </dependency> 
    </dependencies> 
</plugin> 

生成Java類,當我試圖執行cxf-codegen:wsdl2java目標,定義sourceRoot目錄中不產生生成的類。

當我運行mvn與調試選項(-X -e)我得到:

... 
[DEBUG] Configuring mojo org.apache.cxf:cxf-codegen-plugin:2.6.1:wsdl2java from plugin realm ClassRealm[plugin>org.apache.cxf:cxf-codegen-plugin:2.6.1, parent: [email protected]] 
[DEBUG] Configuring mojo 'org.apache.cxf:cxf-codegen-plugin:2.6.1:wsdl2java' with basic configurator --> 
[DEBUG] (f) classesDirectory = C:\WsdlTest\target\classes 
[DEBUG] (f) disableDependencyScan = false 
[DEBUG] (f) disableDirectoryScan = false 
[DEBUG] (f) encoding = UTF-8 
[DEBUG] (f) fork = false 
[DEBUG] (f) javaExecutable = C:\Program Files\Java\jdk1.6.0_31\jre/bin/java 
[DEBUG] (f) localRepository =  id: local 
     url: file:///C:/Users/admi/.m2/repository/ 
    layout: none 

[DEBUG] (f) markerDirectory = C:\WsdlTest\target\cxf-codegen-plugin-markers 
[DEBUG] (f) mavenSession = [email protected] 
[DEBUG] (f) pluginArtifacts = [org.apache.cxf:cxf-codegen-plugin:maven-plugin:2.6.1:, org.codehaus.woodstox:stax2-api:jar:3.0.2:runtime, javax.xml.stream:stax-api:jar:1.0-2:runtime, org.apache.cxf.xjcplugins:cxf-xjc-ts:jar:2.4.0:runtime, commons-lang:commons-lang:jar:2.6:compile, org.jvnet.jaxb2_commons:jaxb2-basics:jar:0.6.3:runtime, org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.6.3:runtime, org.jvnet.jaxb2_commons:jaxb2-basics-tools:jar:0.6.3:runtime, commons-beanutils:commons-beanutils:jar:1.7.0:runtime, org.apache.maven.shared:maven-artifact-resolver:jar:1.0:compile, org.codehaus.plexus:plexus-utils:jar:2.0.5:compile, org.codehaus.plexus:plexus-archiver:jar:1.2:compile, org.codehaus.plexus:plexus-io:jar:1.0.1:compile, org.apache.cxf:cxf-api:jar:2.6.1:compile, org.codehaus.woodstox:woodstox-core-asl:jar:4.1.2:runtime, org.apache.ws.xmlschema:xmlschema-core:jar:2.0.2:compile, org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile, wsdl4j:wsdl4j:jar:1.6.2:compile, org.apache.cxf:cxf-tools-common:jar:2.6.1:compile, org.apache.velocity:velocity:jar:1.7:compile, commons-collections:commons-collections:jar:3.2.1:compile, com.sun.xml.bind:jaxb-xjc:jar:2.1.13:compile, com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile, org.apache.cxf:cxf-rt-core:jar:2.6.1:compile, org.apache.cxf:cxf-tools-wsdlto-core:jar:2.6.1:compile, org.apache.cxf:cxf-tools-validator:jar:2.6.1:compile, org.apache.cxf:cxf-rt-bindings-soap:jar:2.6.1:compile, org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.6.1:compile, org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:jar:2.6.1:compile, org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:jar:2.6.1:compile, xml-resolver:xml-resolver:jar:1.2:compile, org.apache.cxf:cxf-tools-wsdlto-frontend-javascript:jar:2.6.1:compile, org.apache.cxf:cxf-rt-javascript:jar:2.6.1:compile, org.springframework:spring-core:jar:3.0.7.RELEASE:compile, org.springframework:spring-asm:jar:3.0.7.RELEASE:compile, commons-logging:commons-logging:jar:1.1.1:compile, org.springframework:spring-beans:jar:3.0.7.RELEASE:compile, org.springframework:spring-context:jar:3.0.7.RELEASE:compile, org.springframework:spring-aop:jar:3.0.7.RELEASE:compile, aopalliance:aopalliance:jar:1.0:compile, org.springframework:spring-expression:jar:3.0.7.RELEASE:compile, org.apache.ant:ant:jar:1.8.2:compile, org.apache.ant:ant-launcher:jar:1.8.2:compile, org.apache.ant:ant-nodeps:jar:1.8.1:compile] 
[DEBUG] (f) project = MavenProject: com.tmobile.tmo.pfw:ssa:1.0.0-SNAPSHOT @ C:\WsdlTest\pom.xml 
[DEBUG] (f) repositories = [id = 'releases', id = 'snapshots', id = 'central'] 
[DEBUG] (f) sourceRoot = C:\WsdlTest\target\generated-sources\cxf 
[DEBUG] (f) testWsdlRoot = C:\WsdlTest\src\test\resources\wsdl 
[DEBUG] (f) useCompileClasspath = false 
[DEBUG] (f) wsdlRoot = C:\WsdlTest\src\main\resources\wsdl 
[DEBUG] -- end configuration -- 
... 

在另一方面,在mvn clean install源產生很好(生成文件夾中)。但我不想生成每個構建的類。

任何想法有什麼不對?

回答

3

這個問題是很老,但我有同樣的問題,並希望拯救未來的解決方案:

不知何故cxf-codegen-plugin需要一些行家分階段執行,以便能夠「搶」的配置元素,而不是使用默認值。我所做的是從默認構建中刪除該插件並創建一個配置文件,以便能夠將其作爲需求階段的一部分運行,而不是每個構建都運行。

礦看起來像這樣:

<profile> 
    <id>generate-ws-stub</id> 
    <activation> 
     <activeByDefault>false</activeByDefault> 
    </activation> 
    <properties> 
     <version.cxf>2.3.0</version.cxf> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-codegen-plugin</artifactId> 
       <version>${version.cxf}</version> 

       <dependencies> 
        <dependency> 
         <groupId>org.apache.cxf</groupId> 
         <artifactId>cxf-rt-transports-http</artifactId> 
         <version>${version.cxf}</version> 
        </dependency> 
        <dependency> 
         <groupId>org.apache.cxf</groupId> 
         <artifactId>cxf-rt-ws-security</artifactId> 
         <version>${version.cxf}</version> 
        </dependency> 
        <dependency> 
         <groupId>org.apache.cxf</groupId> 
         <artifactId>cxf-rt-core</artifactId> 
         <version>${version.cxf}</version> 
        </dependency> 
       </dependencies>  

       <executions> 
        <execution> 
         <id>generate-sources</id> 
         <phase>generate-sources</phase> 
         <configuration> 
          <sourceRoot>${project.build.sourceDirectory}\prb</sourceRoot> 
          <wsdlOptions> 
           <wsdlOption> 
            <wsdl>${project.build.resources[0].directory}/wsdl/NoneOfYourBusinessWS.wsdl</wsdl> 
            <wsdlLocation>classpath:wsdl/NoneOfYourBusinessWS.wsdl</wsdlLocation> 
            <extraargs> 
             <extraarg>-verbose</extraarg> 
             <extraarg>-impl</extraarg> 
            </extraargs> 
           </wsdlOption> 
          </wsdlOptions> 
         </configuration> 
         <goals> 
          <goal>wsdl2java</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</profile> 

現在,每當我想 「刷新」 我的XML綁定我就跑mvn generate-sources -P generate-ws-stub