I have 2 schemas A, B. I'm reusing some A elements in B.
I do not use namespaces.
I'm using
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.9.0</version>
I have have defined an inclusion of schema A in schema B as:
<xs:include schemaLocation="classpath:my.schema.A.xsd"/>
and the catalog as
REWRITE_SYSTEM "classpath:my.schema.A.xsd" "maven:my.schema:schema-a!/A.xsd"
The jaxb configuration goes:
<configuration>
<generatePackage>my.schema.b</generatePackage>
<schemaIncludes>
<includes>B.xsd</includes>
</schemaIncludes>
<episodes>
<episode>
<groupId>my.schema</groupId>
<artifactId>schema-a</artifactId>
</episode>
</episodes>
<catalog>src/main/catalog/catalog.cat</catalog>
</configuration>
The issue is that whenever I specify the episode dependency the schema does not generate any classes even though it contains some B elements I want to generate the classes for.
[INFO] Parsing input schema(s)...
[INFO] Compiling input schema(s)...
[INFO] Cleaning package directories.
[INFO] Finished execution.
When I remove the episode it works well and generates classes for schema A as well - which I indeed want to avoid.
Do you have any suggestions?
A sample was published in Jaxb episodic compilation
Ok, I've checked your example. The problem is that you don't use namespaces.
Check your
META-INF/sub-jaxb.episode
file:You see this
<jaxb:bindings scd="x-schema::">
and then<jaxb:schemaBindings map="false">
. This basically tells XJC "don't map anything in the empty namespace". Since your second schema (b.xsd
) also does not use namespaces, when you usea.xsd
's episode file (binding above), you suppress generation of code forb.xsd
as well.To sum it up, when using episodes/separate schema compilation you can't put schemas with one namespace into different episodes. This is exactly the issue with
include
.This is not a bug in the
maven-jaxb2-plugin
. I would not also call it a bug in XJC. It's just how episodes work by default.See my pull request here, it demonstrates episodic compilation, when namespaces are handled accordingly.