Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CXF maven plugin generate classes in wrong directory

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 Answers

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>
like image 84
Rich Seller Avatar answered Oct 19 '25 00:10

Rich Seller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!