3

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

2 Answers2

3

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
  • 83,208
  • 23
  • 172
  • 177
1

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 <phase>, as generate-sources is the default.

Thanks for your help

Xavi López
  • 27,550
  • 11
  • 97
  • 161
  • Thanks for this hint. I got into the same trouble. Delete the target directory and it will be re-generated. – ttt Apr 30 '14 at 12:41