XJC: migrating ant task from JAXB to JDK 1.6

We migrated to Java 1.6, and as part of overwriting ant tasks that used the old xjc ant task to use the executable: xjc.exe provided in Java 1.6

We also need to preserve older ant task parameters, such as using the commons-lang plugin to generate toString () methods in the generated value objects.

Earlier:

<target name="generate_vos" description="Compile all Java source files">
    <echo message="Compiling the schema..." />
    <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
        <classpath refid="ERPSimulator.classpath"/>
    </taskdef>
    <delete dir="${jaxb.src}" />
    <mkdir dir="${jaxb.src}" />
    <xjc schema="${jaxb.schema}/SOAPClientObjects.xsd" package="xxx.jaxb.vo" destdir="${jaxb.src}">
        <arg value="-Xcommons-lang" />
        <arg value="-Xcommons-lang:ToStringStyle=SIMPLE_STYLE" />
        <produces dir="${jaxb.src}" includes="**/*.java" />
    </xjc>
</target>

Now:

 <target name="generate_vos" description="Compile all Java source files">       
        <delete dir="${jaxb.src}" />
        <mkdir dir="${jaxb.src}" />
        <echo message="Compiling the schema..." />
         <exec executable="xjc">
             <arg value="-extension"/>
             <arg value="-d"/>
             <arg value="${jaxb.src}"/>
             <arg value="-p"/>
             <arg value="xxxx.jaxb.vo"/>
             <arg value="${jaxb.schema}/SOAPClientObjects.xsd"/>        
             <arg value="-Xcommons-lang"/>
             <arg value="-Xcommons-lang:ToStringStyle=SIMPLE_STYLE" />
         </exec>
</target>

However, starting a new task leads to errors, because the -Xcommons * plugins are not migrated in this version. I explicitly installed the plugin jar files for the Commons-lang toString plugin in the path too without luck.

Any idea how to get XJC.exe to generate the toString () method for the resulting objects?

Thank!

+5
source share

All Articles