If got a Java library which other projects depend on (.jar dependancy through Maven). In this library there is an XSD-file which defines some xs:simpleType
s which are also annotated with xjc:javaType
elements mapping the simple types to already existing java classes and adapter classes in that library. This all works fine, but now I wanted to create a xs:complexType
. I let the org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
version 0.8.2 create some java beans from the complex type and an addition .episode file.
In my second project I import the library, unpack the xsd file into a schema directory and let project2.xsd import the library.xsd, because it uses the simple and complex types. To avoid double generation of already existing beans, I added the libary as an depenancy in the episodes
tag of the org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
. But now the plugin complains that it can't parse the xsd file and throws an exception on every type defintion line.
I presume there is some issue with using episodes (they don't include simpleTypes?) and xjc:javaType
annotations? Is there some kind of workaround to this problem? I can't find much on the web regarding this issue. Grateful for any hint.
I've achieved the same thing by using maven-hyperjaxb3-plugin Check how is done:
<plugin>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>maven-hyperjaxb3-plugin</artifactId>
<version>0.5.4</version>
<executions>
<execution>
<id>id1</id>
<inherited>false</inherited>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<args>
<param>-npa</param>
</args>
<generateDirectory>target/generated-sources/xjc2</generateDirectory>
<generatePackage>com.target.package</generatePackage>
<extension>true</extension>
<schemaIncludes>
<include>mine.xsd</include>
</schemaIncludes>
<forceRegenerate>false</forceRegenerate>
<removeOldOutput>true</removeOldOutput>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.12</version>
</dependency>
</dependencies>
</plugin>
here are the project dependencies:
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-runtime</artifactId>
<version>0.3</version>
</dependency>
<!-- Roundtrip -->
<dependency>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-roundtrip
</artifactId>
<version>0.3</version>
</dependency>
</dependencies>
I have any kind of simple and complex types defined and it works like a charm. Hope it helps!