JAXB2 Basics Mergeable plugin: Setting a custom Merge Strategy
I have successfully activated the JAXB2 Basics 'Mergeable' plugin in an ant script as follows:
<target name="generate-sources" depends="clean">
<xjc destdir="${generated.src.dir}" package="${jaxb.package}" extension="true">
<arg line="
-Xmergeable
-Xinheritance"/>
<binding dir="${altova}">
<include name="**/*.xjb"/>
</binding>
<schema dir="${altova}">
<include name="**/*.xsd"/>
</schema>
<!-- Plugins -->
<classpath>
<fileset dir="${xjc.lib}">
<!-- JAXB2 Basics library -->
<include name="jaxb2-basics-*.jar"/>
<!-- JAXB2 Basics library dependencies -->
<include name="jaxb2-basics-tools-*.jar"/>
<include name="commons-beanutils-*.jar"/>
<include name="commons-lang-*.jar"/>
<include name="commons-logging-*.jar"/>
</fileset>
<fileset dir="${webapp.lib}">
<include name="jaxb2-basics-runtime-*.jar"/>
</fileset>
<!-- Contains custom strategy classes -->
<pathelement location="${webapp.classes}"/>
</classpath>
</xjc>
It is working, and correctly adding the 'MergeFrom' interface to my generated classes.
My problem is that whenever I try to specify a custom merging strategy using the 'mergeStrategyClass' argument, the 'MergeFrom' interface disappears entirely from the generated class. The syntax I am using is as follows:
<arg line="
-Xmergeable-mergeStrategyClass=com.acme.foo.CustomMer开发者_Python百科geStrategy
-Xinheritance"/>
This is taken straight from the example on the JAXB2 Basics website. (The classpath seems to be fine, as when I deliberately miss-spell the class, I get a ClassNotFoundException)
There are no errors being thrown by the ant build, and the classes are generated successfully, except for the missing interface.
You need to have 2 arguments. One to activate mergeable plugin and one to specify the custom merge strategy class.
-Xmergeable
-Xmergeable-mergeStrategyClass=com.acme.foo.CustomMergeStrategy
精彩评论