0

My goal is to generate a java code from XSD using maven-jaxb2-plugin, and in particular from 3 separate schemas. The problem I am facing is that all schemas have dependency on a common schema and the same classes are generated three times.

The part of the pom I am using is shown below:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.6</version>
        <executions>
            <execution>
                <id>xjc-a</id>
                <goals>
                    <goal>xjc</goal>
                </goals>
                <configuration>
                    <packageName>com.a</packageName>
                    <schemaDirectory>src/main/resources/a</schemaDirectory>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
            </execution>
            <execution>
                <id>xjc-b</id>
                <goals>
                    <goal>xjc</goal>
                </goals>
                <configuration>
                    <packageName>com.b</packageName>
                    <schemaDirectory>src/main/resources/b</schemaDirectory>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
            </execution>
            <execution>
                <id>xjc-c</id>
                <goals>
                    <goal>xjc</goal>
                </goals>
                <configuration>
                    <packageName>com.c</packageName>
                    <schemaDirectory>src/main/resources/c</schemaDirectory>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
            </execution>

    </executions>
    </plugin>

Schemas a, b, c all include a common schema, say d. When the sources are generated class from d are generated in each package and what I wish to do is to factor out the common classes into a separate package. Thanks

kostas
  • 1,959
  • 1
  • 24
  • 43
  • If you're using `maven-jaxb2-plugin`, you can easily use [episodes](https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-Episodes) for [modular schema compilation](https://github.com/highsource/maven-jaxb2-plugin/wiki/Modular-Schema-Compilation). But your XML fragment shows you're using `jaxb2-maven-plugin` which is a different plugin. – lexicore Mar 23 '16 at 12:39
  • [See This answer](http://stackoverflow.com/a/24873963/3364187) – Xstian Mar 24 '16 at 14:33

0 Answers0