18
votes

I'm trying to get the cxf-codegen-plugin to generate sources from my wsdl file. When calling wsdl2java manual the desired classes are generated but when using mvn generate-sources nothing happens and I get the message "No goals needed for project". Calling the plugin directly doesn't helps.

The extract from my poms follows:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>2.5.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/MyServiceInterface.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>
3

3 Answers

22
votes

That looks very much like the way I (successfully) configure that plugin in one of my projects; I would expect that to work. (I believe you can omit the <sourceRoot>; the default setting for that is the one you've stated.)

The only thing I can think of would be if you had put that plugin configuration in either a non-active Maven profile or (more likely) in the <pluginManagement> section instead of the straight <plugins> section; the pluginManagement section overrides aspects of the configuration of plugins, but doesn't actually enable them for use. (It does however affect explicit usage; I know you don't want to do that.)

2
votes

In my case at least, I thought it wasn't generating source code as well, but it actually was. The issue was that the folder target/generated/cxf was designated by Eclipse as a source folder, which I didn't do manually. So the source was toward the top of my project, in package structure, not in the folder structure below, which is where I was looking and expecting it to be.

0
votes

In my case as long as I had the old target directory (defined in <sourceRoot>/path/to/target</sourceRoot>) nothing was being generated. Only after deleting the target folder manually plugin actually started to generate the sources.