Generating classes from multiple wsdl files using maven-jaxb2-plugin

Wlad picture Wlad · May 3, 2016 · Viewed 10.5k times · Source

I can generate classes from one wsdl file like this:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.12.3</version>
    <configuration>
        <schemaLanguage>WSDL</schemaLanguage>
        <schemaDirectory>src/main/resources</schemaDirectory>
        <schemaIncludes>
            <include>bwl_1_1.wsdl</include>
        </schemaIncludes>
        <generatePackage>bwl.wsdl</generatePackage>
        <generateDirectory>${project.build.directory}/generated-sources/bwl</generateDirectory>
    </configuration>
</plugin>

When I try using multiple <plugin>, just one of them is generated. I found that if I want to generate classes from multiple files, I should use <executions>. However when I wrap <configuration> into <executions>, it no longer generates, in fact it generates something from xsd file in the directory...

My not working attempt:

    <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.12.3</version>

        <executions>
            <execution>
                <id>bwl</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <schemaDirectory>src/main/resources</schemaDirectory>
                    <schemaIncludes>
                        <include>bwl_1_1.wsdl</include>
                    </schemaIncludes>
                    <generatePackage>bwl.wsdl</generatePackage>
                    <generateDirectory>${project.build.directory}/generated-sources/bwl</generateDirectory>
                </configuration>
            </execution>

            <execution>
                <id>score</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <schemaDirectory>src/main/resources</schemaDirectory>
                    <schemaIncludes>
                        <include>score_1_1.wsdl</include>
                    </schemaIncludes>
                    <generatePackage>score.wsdl</generatePackage>
                    <generateDirectory>${project.build.directory}/generated-sources/score</generateDirectory>
                </configuration>
            </execution>
        </executions>

    </plugin>

Thank you.

Answer

shaunthomas999 picture shaunthomas999 · Jul 24, 2016

Add ${basedir} in front of the path in <schemaDirectory> tag as follows

<schemaDirectory>${basedir}/src/main/resources</schemaDirectory>

Then it should work!