I am trying to use xjc compiler from ant. Builds successfully but nothing gets generated.
My ant script is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project name="AutomateWithAnt" basedir=".">
<property file="build.properties"/>
<path id="compile.classpath">
<fileset dir="${lib.includes}" includes="*.jar"></fileset>
</path>
<target name="init" description="create java class">
</target>
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="compile.classpath"/>
<!-- Generates the source code from the test.xsd schema using jaxb -->
<target name="option-generate" description="Generates the source code" depends="init">
<xjc schema="test.xsd" destdir="${generated-src.dir}" package="${generated-src.dir}">
<arg value="-Xcommons-lang" />
<arg value="-Xcommons-lang:ToStringStyle=SHORT_PREFIX_STYLE" />
<produces dir="${generated-src.dir}" includes="**/*.java" />
</xjc>
</target>
</project>
my build.properties is:
lib.includes=lib/
generated-src.dir=/
I am using java 1.6 and I have used jaxb-sjc.jar.
You’ve defined 2 Ant targets (
initandoption-generate), but neither of them will be invoked unless you specify which one to run.You either need to specify it on the command line, e.g.
or add a default target to the
<project>element, e.g.Incidentally, your
inittarget is empty, and therefore pointless.