| Target | Description |
|---|
| gen.castor | generate castor mapping.xml |
<?xml version="1.0" encoding="UTF-8"?>
<project name="castor">
<description>
+ ==\_/============J=A=V=A=G=E=N===A=N=T===M=O=D=U=L=E=S================= +
+ \(_)/ +
+ -(_)- Castor XML Databinding Module +
+ /(_)\ +
+ ======================================================================= +
+ Copyright (c) 2002-2005 Outsource Cafe, Inc. All rights reserved. +
+ ======================================================================= +
+
+ This file defines targets for XDoclet-based Castor XML databinding code
+ generation. The Java-XML databinding mapping is determined by attributes
+ in java files. Files to process are determined by the 'castor.xml.include'
+ and 'castor.xml.patternset' naming pattern properties. The default naming
+ pattern is '**/*.DTO.java'.
+
+ Public targets:
+ gen.castor - generate castor mapping.xml
+
+ Prerequisite imports:
+ props-global.xml, classpath.xml
+
+ Optional properties:
+ castor.xml.include - Naming pattern to identify files to process
+ castor.xml.patternset- Naming pattern sets.
+ itestfork - fork unit tests, default: 'false'
+ castor.mapping.dir - location of mapping.xml output file
+
+ Prerequisit properties:
+ xdoclet.dto.suffix - default source naming pattern
+
+ developer: RichardEasterling@OutsourceCafe.com
+ ======================================================================= +
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ =J=A=M===========================================J=A=V=A=G=E=N=.=C=O=M= +
</description>
<taskdef name="ejbdoclet" classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="xdoclet.classpath"></taskdef>
<!-- =================================================================== -->
<!-- standard target -->
<!-- =================================================================== -->
<target name="gen.castor" depends="castor.ejbdoclet,castor.rename.dd" description="generate castor mapping.xml"></target>
<!-- ===================================================================== -->
<!-- patternset to identify XML databinding classes -->
<!-- ===================================================================== -->
<property name="castor.xml.include" value="**/*${xdoclet.dto.suffix}.java"></property>
<property name="castor.xml.exclude" value="NO-FILE-SPECIFIED/*"></property>
<!--
<patternset id="castor.xml.patternset">
<include name="${castor.xml.include}"/>
<include name="**/*XmlDataLoader.java"/>
</patternset>
-->
<!-- ===================================================================== -->
<!-- output properties -->
<!-- ===================================================================== -->
<property name="castor.mapping.dir" location="${build.resources.dir}"></property>
<property name="castor.mapping.name" value="mapping.xml"></property>
<condition property="castor-rename-dd">
<not>
<equals arg1="${castor.mapping.name}" arg2="mapping.xml"></equals>
</not>
</condition>
<echo>castor-rename-dd = ${castor-rename-dd}</echo>
<!-- =================================================================== -->
<!-- Generates the supporing EJB classes and deployment descriptors -->
<!-- =================================================================== -->
<target name="castor.uptodate" depends="">
<uptodate property="castor-uptodate" targetfile="${castor.mapping.dir}/mapping.xml">
<srcfiles dir="${src.java.dir}" includes="${castor.xml.include}" excludes="${castor.xml.exclude}"></srcfiles>
<srcfiles dir="${gen.java.dir}" includes="${castor.xml.include}" excludes="${castor.xml.exclude}"></srcfiles>
<!--
<patternset refid="castor.xml.patternset"/>
</srcfiles>
<srcfiles dir="${gen.java.dir}">
<patternset refid="castor.xml.patternset"/>
</srcfiles>
-->
</uptodate>
<echo>castor-uptodate = ${castor-uptodate}</echo>
<echo>castor.xml.include = ${castor.xml.include}</echo>
</target>
<!-- =================================================================== -->
<!-- Generates castor mapping.xml file from DTD java source -->
<!-- =================================================================== -->
<target name="castor.ejbdoclet" unless="castor-uptodate" depends="castor.uptodate">
<echo>generating Castor binding: ${castor.mapping.dir}/mapping.xml</echo>
<ejbdoclet destdir="${build.classes.dir}" excludedtags="${xdoclet.excludedtags}" ejbspec="${ejb.spec.version}" force="${xdoclet.force}" mergedir="${xdoclet.merge.dir}">
<fileset dir="${src.java.dir}" includes="${castor.xml.include}" excludes="${castor.xml.exclude}"></fileset>
<fileset dir="${gen.java.dir}" includes="${castor.xml.include}" excludes="${castor.xml.exclude}"></fileset>
<!--
<patternset refid="castor.xml.patternset"/>
</fileset>
<fileset dir="${gen.java.dir}">
<patternset refid="castor.xml.patternset"/>
</fileset>
-->
<castormapping validatexml="${xdoclet.validatexml}" destDir="${castor.mapping.dir}"></castormapping>
</ejbdoclet>
<!--destdir="${build.ejb.xdoc.dir}"-->
</target>
<!-- =================================================================== -->
<!-- if set renames 'mapping.xml' to ${castor.mapping.name} -->
<!-- =================================================================== -->
<target name="castor.rename.dd" if="castor-rename-dd">
<move file="${castor.mapping.dir}/mapping.xml" tofile="${castor.mapping.dir}/${castor.mapping.name}"></move>
</target>
<!-- =================================================================== -->
<!-- utility macro for testing databinding. Better to write unit tests! -->
<!-- =================================================================== -->
<macrodef name="castor.testdata.macro">
<attribute name="class" default="${castor.testdata.class}"></attribute>
<attribute name="datafile" default="${castor.testdata.file}"></attribute>
<attribute name="classpathref" default="build.classpath"></attribute>
<attribute name="fork" default="yes"></attribute>
<element name="body.tag" optional="yes"></element>
<sequential>
<echo>class =@{class}</echo>
<echo>datafile =@{datafile}</echo>
<echo>classpathref =@{classpathref}</echo>
<java classname="@{class}" fork="@{fork}" classpathref="@{classpathref}">
<arg line="@{datafile}"></arg>
<body.tag></body.tag>
</java>
</sequential>
</macrodef>
</project>