views:

1426

answers:

3

Hi,

I'm using maven cxf-codegen-plugin to generate java web service files from wsdl. The plugin works fine if I'm trying to generate the files in the default output directory (target\generated-sources\cxf), but if I'm trying to generate them in other directory by using:

<sourceRoot>src/main/myOtherDir</sourceRoot>

in my pom.xml, the files are generated only if I do:

mvn clean eclipse:eclipse

If I do

mvn eclipse:eclipse

without 'clean' the files are not generated...

Does anyone have any idea....?

My pom:

  <plugin>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-codegen-plugin</artifactId>
   <version>${cxf.version}</version>
   <executions>
    <execution>
     <id>generate-sources</id>
     <configuration>
      <sourceRoot>src/main/myOtherDir</sourceRoot> 
      <wsdlOptions>
       <wsdlOption>
        <wsdl>src/main/resources/wsdl/AccountWS.wsdl</wsdl>
       </wsdlOption>
      </wsdlOptions>
     </configuration>
     <goals>
      <goal>wsdl2java</goal>
     </goals>
    </execution>
   </executions>
  </plugin>
 </plugins>

Thanks, Alon

+1  A: 

You are better off setting the sourceRoot below the target directory so it is cleaned along with other content, e.g.:

<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>

To ensure the plugin always executes, you need to bind it to a phase, e.g.

<executions>
  <execution>
    <id>generate-sources</id>
    <phase>process-resources</phase>
    ...
    <goals>
      <goal>wsdl2java</goal>
    </goals>
  </execution>
Rich Seller
A: 

It's really better to set the sourceRoot below the target directory, but unfortunately I have to generate them in other directory. I did the change you've suggested, and it still didn't work:

  <plugin>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-codegen-plugin</artifactId>
   <version>${cxf.version}</version>
   <executions>
    <execution>
     <id>generate-sources</id>
     <phase>process-resources</phase>
     <configuration>
      <sourceRoot>src/main/myOtherDir</sourceRoot> 
      <wsdlOptions>
       <wsdlOption>
        <wsdl>src/main/resources/wsdl/AccountWS.wsdl</wsdl>
       </wsdlOption>
      </wsdlOptions>
     </configuration>
     <goals>
      <goal>wsdl2java</goal>
     </goals>
    </execution>
   </executions>
  </plugin>
Alon
A: 

Well I found the problem, Very embarrassing... Because I didn't update the wsdl, the plugin did not generate the files...

Anyway, the apache cfx documentation states that: For CXF 2.1.4 and latter you don't need anymore to specify the , as generate-sources is the default.

Thanks for your help

Alon
Please accept your own answer to close this question.
Tim