1

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.CustomMergeStrategy
    -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.

lexicore
  • 42,748
  • 17
  • 132
  • 221
got_bainne
  • 76
  • 4
  • I cannot reproduce this. Please file an issue here (http://jira.highsource.org/browse/JIIB) and send a sample project which demonstrates the problem. From the code, I can't really imagine that this is happening. `MyClass implements MergeFrom` is the first thing which is done with classes. – lexicore Jul 14 '11 at 13:45
  • Still waiting for the issue to be filed. – lexicore Sep 11 '11 at 18:18

1 Answers1

1

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

Gapchoos
  • 1,422
  • 5
  • 20
  • 40
Ryan Moore
  • 11
  • 1