Reputation: 1561
I have multiple xsd schema file which contains multiple/common duplicate xs:element / class entry. I tried them converting into classes using following lines in pom.xml
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>schema1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/xsd/schema1</schemaDirectory>
<schemaIncludes>
<include>schema1.xsd</include>
</schemaIncludes>
<packageName>com.schema1.rest.stub</packageName>
</configuration>
</execution>
<execution>
<id>schema2</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/xsd/schema2</schemaDirectory>
<schemaIncludes>
<include>schema2.xsd</include>
</schemaIncludes>
<packageName>com.schema2.rest.stub</packageName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
While running with only one execution
tag I am getting classes successfully. But when I include two or more than two schema or execution
tag, I am able see only the classes created for last schema "schema2" and not for "schema1".
While running in the command line logs, I can see the classes are getting generated for both of the schema. But the resultant is deleting the older package and recreating it. Basically I am having only classes for the last schema only and not for other schemas.
How I can resolve it?
Upvotes: 0
Views: 1258
Reputation: 1561
Use <clearOutputDir>false</clearOutputDir>
in both <configuration>
tag.
eg:
<configuration>
<clearOutputDir>false</clearOutputDir>
<schemaDirectory>src/main/resources/xsd/schema2</schemaDirectory>
<schemaIncludes>
<include>schema2.xsd</include>
</schemaIncludes>
<packageName>com.schema2.rest.stub</packageName>
</configuration>
Upvotes: 1