How to prevent cxf-codegen-plugin from generating sources for all wsdl files

Viewed 438

I have a problem with cxf-codegen-plugin plugin. I have 2 .wsdl files in src/main/resources/wsdl folder. I want cxf-codegen-plugin to generate sources just for one of them:

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

The result is unexpected, because I can see generated sources for the second wsdl too. It seems that cxf-codegen-plugin is ignoring provided option and generating sources for all wsdl files. Any ideas why? Am I missing something?

1 Answers

I think the <wsdlOptions> just provides options at a WSDL level - it does not select which WSDLs to process.

You can specify which WSDLs to process using <wsdlRoot> and ,<includes>:

<configuration>
  ...
  <wdslRoot>${basedir}/src/main/resources/wsdl</wsdlRoot>
  <includes>
    <include>A.wsdl</include>
  </includes>
</configuration>

See CXF Doco Example 5

You can declare a common wsdlRoot folder where you store your WSDL files and use includes/excludes patterns to select the files to get used by the code generator.

Related