Because of various issues with the XSDs I need to compile (described in other SO posts), I have a bindings file and also a local extension schema. The following command line works correctly, but I'm having trouble figuring out the right pom.xml
configuration to mimic this:
xjc -nv src/main/resources/TCIP_4_0_0_Final.xsd src/main/resources/local/ObaCcLocationReport.xsd -b src/main/resources/local/rename.xjb -d target
Mainly, how do I specify more than one XSD? I tried:
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>TCIP_4_0_0_Final.xsd</include>
<include>local/ObaCcLocationReport.xsd</include>
</schemaIncludes>
but it seemed to ignore the second include
.
I also tried variations on:
<schema>
<fileset>
<directory>src/main/resources</directory>
<includes>
<include>TCIP_4_0_0_Final.xsd</include>
<include>local/ObaCcLocationReport.xsd</include>
</includes>
</fileset>
</schema>
without success. Suggestions?
EDIT
This works as a workaround, but it's not ideal:
Since ObaCcLocationReport.xsd
depends on schemas that get compiled as part of TCIP_4_0_0_Final.xsd
, I just had to make sure it got compiled after that, and it seems to process files in filepath order. So I put the ObaCcLocationReport.xsd
into an x
subfolder and changed the pom.xml
to:
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>TCIP_4_0_0_Final.xsd</include>
<include>x/ObaCcLocationReport.xsd</include>
</schemaIncludes>
This compiled the schemas and generated the Java files correctly.
Disclaimer: I am the author of the maven-jaxb2-plugin.
So your compilation depends on the order of the schema files in the XJC command? Hm, interesting. Why?
Please post
mvn -X clean generate-sources
log in such cases.It really seems that Maven does not maintain the order of the file patterns as I also get:
Which is not what you want. Can be fixed, please file an issue. (I rely on one of the Maven libraries here, but can do it differently to maintain the order.)
You can configure it as follows:
Gives you:
Notes:
<schemaIncludes/>
otherwisesrc/main/resources/*.xsd
will be included by default.<strict>false</strict>
gives you-nv
.args
/arg
to configurexjc
on the low level, but I won't recommend it.