hi all,
attached you'll find a SourceGenerator Ant Task, I have implemented.
About
===============
It is a simple task definition that behaves somewhat like other java-based
tasks (for instance Junit task ).
You can invoke it in the same vm or in an external vm, both of which are
equivalent.
The sources plus the binary distribution is attached.
Attached you also find a simple albeit somewhat degenerated build sample.
An important thing is that there is no dependency for ant to have a 'outer'
classpath reference to castor.jar, it is enough to simply add the castor.jar
to the classpath inside the build file.
(This gets achieved by using the ant classloader for which you can change
the classpath at runtime).
Todo
===============
* It would be great if we could control the properties of the
castorbuilder.properties file
through ant-build-file _without_ the need of an external
castorbuilder.properties file.
* Anybody that has a good idea how to extend or improve my bits please
contribute.
sample task to generate src from the invoice.xsd schema.
<castor-srcgen schema="invoice.xsd"
types="j2"
destdir="./src"
lineseparator="win"
testable="yes"
nomarshall="yes"
nodesc="yes"
suppressnonfatalwarnings="yes"
fork="no"
>
<classpath refid="project.class.path" />
</castor-srcgen>
bye
Jakob
invoice.xsd
<?xml version="1.0"?>
<project name="srcgen-anttask" basedir="." default="all">
<taskdef name="castor-srcgen" classname="com.prahersoft.antTasks.castor.SrcGenTask"/>
<property name="castor.jar" value="..." />
<property name="ant.jar" value="..." />
<!-- Set the properties for intermediate directory -->
<property name="build.dir" value="./build" />
<property name="build.classes" value="${build.dir}/classes" />
<!-- Set the properties for source directories -->
<property name="src.dir" value="./src" />
<property name="java.dir" value="${src.dir}/java" />
<property name="test.dir" value="./test" />
<path id="project.class.path">
<pathelement location="${castor.jar}" />
<pathelement location="${ant.jar}" />
<pathelement location="srcgen-anttask.jar" />
</path>
<target name="init">
</target>
<target name="generate-src" depends="init">
<!--
===============================================================
first task runs inside the vm
-->
<castor-srcgen schema="invoice.xsd"
types="j2"
destdir="./src"
lineseparator="win"
testable="yes"
nomarshall="yes"
nodesc="yes"
suppressnonfatalwarnings="yes"
>
<classpath refid="project.class.path" />
</castor-srcgen>
<!--
================================================================
this tasks runs outside the vm
-->
<castor-srcgen schema="invoice.xsd"
types="j2"
destdir="./src2"
lineseparator="win"
testable="yes"
nomarshall="yes"
nodesc="yes"
suppressnonfatalwarnings="yes"
fork="yes"
>
<classpath refid="project.class.path" />
</castor-srcgen>
</target>
<target name="all" depends="generate-src, init">
</target>
</project>
srcgen-anttask.jar
srcgen-anttask-src.jar