<project name="Torque" default="main" basedir=".">
<property name="torque.home" value=".."/>
<property name="build.properties" value="build.properties"/>
<property file="${build.properties}"/>
<property name="lib.dir" value="../lib/share"/>
<property name="idTableXMLFile" value="../conf/idtable/id-table-schema.xml"/>
<!-- Build classpath -->
<path id="torque-classpath">
<fileset dir="../lib/share">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- ================================================================ -->
<!-- M A I N T A R G E T -->
<!-- ================================================================ -->
<!-- This default target will run all the targets that generate -->
<!-- source. You will probably only run this target once then -->
<!-- call individual targets as necessary to update your sources -->
<!-- when you change your XML schema. -->
<!-- ================================================================ -->
<target name="echotcp">
<property name="tcp" refid="torque-classpath"/>
<echo>torque-classpath = ${tcp}</echo>
</target>
<target
name="main"
description="==> generates sql + om classes">
<antcall target="project-sql"/>
<antcall target="project-om"/>
</target>
<target
name="main-classpath"
description="==> generates sql + om classes">
<antcall target="project-sql-classpath"/>
<antcall target="project-om-classpath"/>
</target>
<!-- ================================================================ -->
<!-- G E N E R A T E P R O J E C T S Q L -->
<!-- ================================================================ -->
<!-- Generate the SQL for your project, these are in addition -->
<!-- to the base Turbine tables! The tables you require for your -->
<!-- project should be specified in project-schema.xml. -->
<!-- ================================================================ -->
<target
name="project-sql"
description="==> generates the SQL for your project">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating SQL for YOUR ${Project} ! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="torque-sql"
classname="org.apache.torque.task.TorqueSQLTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-sql
contextProperties="${build.properties}"
controlTemplate="${SQLControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}/sql"
templatePath="${templatePath}"
basePathToDbProps="sql/base/"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputFile="report.${project}.sql.generation"
targetDatabase="${database}"
idTableXMLFile="${idTableXMLFile}">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</torque-sql>
</target>
<!-- ================================================================ -->
<!-- G E N E R A T E D O C S -->
<!-- ================================================================ -->
<target
name="project-doc"
description="==> generates documentation for your datamodel">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating docs for YOUR datamodel! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<antcall target="echotcp"/>
<taskdef
name="torque-doc"
classname="org.apache.torque.task.TorqueDocumentationTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-doc
contextProperties="${build.properties}"
controlTemplate="${DocControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}/doc"
outputFormat="${documentationFormat}"
templatePath="${templatePath}"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputFile="report.${project}.doc.generation">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</torque-doc>
</target>
<!-- ================================================================ -->
<!-- C R E A T E T A R G E T D A T A B A S E -->
<!-- ================================================================ -->
<!-- Create the target database by executing a generated script -->
<!-- that is capable of performing the task. -->
<!-- ================================================================ -->
<target
name="project-create-db"
unless="database.manual.creation"
description="==> generates the target database">
<taskdef
name="torque-create-db"
classname="org.apache.torque.task.TorqueDataModelTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-create-db
controlTemplate="sql/db-init/Control.vm"
outputDirectory="${torque.home}/${outputDirectory}/sql"
targetDatabase="${database}"
templatePath="${templatePath}"
outputFile="create-db.sql">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</torque-create-db>
<echo>
Executing the create-db.sql script ...
</echo>
<sql
driver="${databaseDriver}"
url="${createDatabaseUrl}"
userid="${databaseUser}"
password="${databasePassword}"
src="${torque.home}/${outputDirectory}/sql/create-db.sql"
autocommit="true"
onerror="continue">
<classpath refid="torque-classpath"/>
</sql>
</target>
<!-- ================================================================ -->
<!-- I N S E R T S I N G L E S Q L F I L E S -->
<!-- ================================================================ -->
<target
name="project-insert-sql">
<taskdef
name="torque-insert-sql"
classname="org.apache.torque.task.TorqueSQLExec">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-insert-sql
driver="${databaseDriver}"
url="${buildDatabaseUrl}"
userid="${databaseUser}"
password="${databasePassword}"
autocommit="true"
onerror="continue"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
srcDir="${torque.home}/${outputDirectory}/sql">
<classpath refid="torque-classpath"/>
</torque-insert-sql>
</target>
<!-- ================================================================ -->
<!-- J D B C TO X M L -->
<!-- ================================================================ -->
<target
name="project-jdbc"
description="==> jdbc to xml">
<echo message="+-----------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating XML from JDBC connection ! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+-----------------------------------------------+"/>
<echo message=" taking build.properties from: ${build.properties}"/>
<taskdef
name="torque-jdbc"
classname="org.apache.torque.task.TorqueJDBCTransformTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-jdbc
dbUrl="${databaseUrl}"
dbDriver="${databaseDriver}"
dbUser="${databaseUser}"
dbPassword="${databasePassword}"
dbSchema="${databaseSchema}"
outputFile="${torque.home}/${outputDirectory}/schema.xml"
sameJavaName="${sameJavaName}"
/>
</target>
<!-- ================================================================ -->
<!-- Generate SQL from XML data file -->
<!-- ================================================================ -->
<target
name="project-datasql"
description="==> generates sql from data xml">
<echo message="+-----------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating SQL from data XML ! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+-----------------------------------------------+"/>
<echo message=" taking build.properties from: ${build.properties}"/>
<taskdef
name="torque-datasql"
classname="org.apache.torque.task.TorqueDataSQLTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-datasql
contextProperties="${build.properties}"
controlTemplate="${DataSQLControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}"
templatePath="${templatePath}"
outputFile="${project}-data.sql"
xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
dataXmlFile="${torque.home}/${schemaDirectory}/${project}-data.xml"
dataDTD="${torque.home}/${schemaDirectory}/${project}-data.dtd"
targetDatabase="${database}"
sqldbmap="${basedir}/${outputDirectory}/sql/sqldb.map"
/>
</target>
<!-- ================================================================ -->
<!-- G E N E R A T E I D B R O K E R I N I T S Q L -->
<!-- ================================================================ -->
<target
name="id-table-init-sql">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating initialization SQL |"/>
<echo message="| for ID Broker system! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="torque-sql"
classname="org.apache.torque.task.TorqueSQLTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-sql
contextProperties="${templatePath}/sql/id-table/project.props"
controlTemplate="${idTableControlTemplate}"
templatePath="${templatePath}"
suffix="-idtable-init"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputDirectory="${torque.home}/${outputDirectory}/sql"
outputFile="${database}-id-table-init.sql"
targetDatabase="${database}">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
<exclude name="id-table-schema.xml"/>
</fileset>
</torque-sql>
</target>
<!-- ================================================================ -->
<!-- Dump data from database into xml file -->
<!-- ================================================================ -->
<target
name="project-datadump"
description="==> dump data from database into xml file">
<echo message="+-----------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Dumping the data from database into XML |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+-----------------------------------------------+"/>
<echo message=" taking build.properties from: ${build.properties}"/>
<taskdef
name="torque-datadump"
classname="org.apache.torque.task.TorqueDataDumpTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-datadump
contextProperties="${build.properties}"
controlTemplate="${DataDumpControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}"
templatePath="${templatePath}"
outputFile="report.${project}.datadump.generation"
xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
databaseDriver="${databaseDriver}"
databaseUrl="${databaseUrl}"
databaseUser="${databaseUser}"
databasePassword="${databasePassword}"
databaseName="${databaseName}"
/>
</target>
<!-- ================================================================ -->
<!-- G E N E R A T E P R O J E C T D A T A D T D -->
<!-- ================================================================ -->
<!-- Generate the DATA DTD for your project -->
<!-- ================================================================ -->
<target
name="project-datadtd"
description="==> generates the DATA DTD for your project">
<echo message="+-----------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating Data DTD for YOUR Turbine project! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+-----------------------------------------------+"/>
<taskdef
name="torque-datadtd"
classname="org.apache.torque.task.TorqueDataModelTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-datadtd
contextProperties="${build.properties}"
controlTemplate="${DataDTDControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}"
templatePath="${templatePath}"
outputFile="report.${project}.datadtd.generation"
xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
/>
</target>
<!-- ================================================================ -->
<!-- G E N E R A T E P R O J E C T P E E R B A S E D O M -->
<!-- ================================================================ -->
<!-- Generate the Peer-based object model for your project. -->
<!-- These are in addition to the base Turbine OM! -->
<!-- ================================================================ -->
<target
name="project-om"
description="==> generates the Peer-based object model for your project">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating Peer-based Object Model for |"/>
<echo message="| YOUR Turbine project! Woo hoo! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="torque-om"
classname="org.apache.torque.task.TorqueDataModelTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-om
contextProperties="${build.properties}"
controlTemplate="${OMControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}"
templatePath="${templatePath}"
outputFile="report.${project}.om.generation"
targetPackage="${targetPackage}.om"
targetDatabase="${database}">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
<exclude name="id-table-schema.xml"/>
</fileset>
</torque-om>
</target>
<!-- ================================================================ -->
<!-- G E N E R A T E P R O J E C T S Q L -->
<!-- ================================================================ -->
<!-- Generate the SQL for your project, these are in addition -->
<!-- to the base Turbine tables! The tables you require for your -->
<!-- project should be specified in project-schema.xml. -->
<!-- ================================================================ -->
<target
name="project-sql-classpath"
description="==> generates the SQL for your project">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating SQL for YOUR Turbine project! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="torque-sql"
classname="org.apache.torque.task.TorqueSQLTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-sql
contextProperties="${build.properties}"
controlTemplate="${SQLControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}/sql"
useClasspath="true"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputFile="report.${project}.sql.generation"
targetDatabase="${database}"
>
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</torque-sql>
</target>
<!-- ================================================================ -->
<!-- Generate SQL from XML data file -->
<!-- ================================================================ -->
<target
name="project-datasql-classpath"
description="==> generates sql from data xml">
<echo message="+-----------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating SQL from data XML ! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+-----------------------------------------------+"/>
<echo message=" taking build.properties from: ${build.properties}"/>
<taskdef
name="torque-datasql"
classname="org.apache.torque.task.TorqueDataSQLTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-datasql
contextProperties="${build.properties}"
controlTemplate="${DataSQLControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}"
useClasspath="true"
outputFile="${project}-data.sql"
xmlFile="${torque.home}/${schemaDirectory}/${project}-schema.xml"
dataXmlFile="${torque.home}/${schemaDirectory}/${project}-data.xml"
dataDTD="${torque.home}/${schemaDirectory}/${project}-data.dtd"
targetDatabase="${database}"
sqldbmap="${basedir}/${outputDirectory}/sql/sqldb.map"
/>
</target>
<!-- ================================================================ -->
<!-- G E N E R A T E P R O J E C T P E E R B A S E D O M -->
<!-- ================================================================ -->
<!-- Generate the Peer-based object model for your project. -->
<!-- These are in addition to the base Turbine OM! -->
<!-- ================================================================ -->
<target
name="project-om-classpath"
description="==> generates the Peer-based object model for your project">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating Peer-based Object Model for |"/>
<echo message="| YOUR Turbine project! Woo hoo! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="torque-om"
classname="org.apache.torque.task.TorqueDataModelTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-om
contextProperties="${build.properties}"
controlTemplate="${OMControlTemplate}"
outputDirectory="${torque.home}/${outputDirectory}/java"
useClasspath="true"
outputFile="report.${project}.om.generation"
targetPackage="${targetPackage}.om"
targetDatabase="${database}">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
<exclude name="id-table-schema.xml"/>
</fileset>
</torque-om>
</target>
<!-- ================================================================ -->
<!-- C R E A T E T A R G E T D A T A B A S E -->
<!-- ================================================================ -->
<!-- Create the target database by executing a generated script -->
<!-- that is capable of performing the task. -->
<!-- ================================================================ -->
<target
name="project-create-db-classpath"
unless="database.manual.creation"
description="==> generates the target database">
<taskdef
name="torque-create-db"
classname="org.apache.torque.task.TorqueCreateDatabase">
<classpath refid="torque-classpath"/>
</taskdef>
<echo>
driver="${databaseDriver}"
url="${createDatabaseUrl}"
userid="${databaseUser}"
password="${databasePassword}"
</echo>
<torque-create-db
controlTemplate="sql/db-init/Control.vm"
outputDirectory="${torque.home}/${outputDirectory}/sql"
targetDatabase="${database}"
useClasspath="true"
outputFile="create-db.sql">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</torque-create-db>
<sql
driver="${databaseDriver}"
url="${createDatabaseUrl}"
userid="${databaseUser}"
password="${databasePassword}"
src="${torque.home}/${outputDirectory}/sql/create-db.sql"
autocommit="true"
onerror="continue">
<classpath refid="torque-classpath"/>
</sql>
</target>
<!-- ================================================================ -->
<!-- G E N E R A T E I D B R O K E R I N I T S Q L -->
<!-- ================================================================ -->
<target
name="id-table-init-sql-classpath">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating initialization SQL |"/>
<echo message="| for ID Broker system! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="torque-sql"
classname="org.apache.torque.task.TorqueSQLTask">
<classpath refid="torque-classpath"/>
</taskdef>
<torque-sql
contextProperties="sql/id-table/project.props"
controlTemplate="${idTableControlTemplate}"
useClasspath="true"
suffix="-idtable-init"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputDirectory="${torque.home}/${outputDirectory}/sql"
outputFile="${database}-id-table-init.sql"
targetDatabase="${database}">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
<exclude name="id-table-schema.xml"/>
</fileset>
</torque-sql>
</target>
<!-- =================================================================== -->
<!-- C O M P I L E O M -->
<!-- =================================================================== -->
<target
name="compile"
description="==> compiles the OM classes">
<!--
This should be moved to the top of the file, and
the values should come from the build.properties file.
-->
<property name="src.dir" value="${outputDirectory}/java"/>
<property name="build.dest" value="bin/classes"/>
<property name="debug" value="on"/>
<property name="deprecation" value="off"/>
<property name="optimize" value="off"/>
<mkdir dir="${build.dest}"/>
<javac srcdir="${src.dir}"
destdir="${build.dest}"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}">
<classpath refid="torque-classpath"/>
</javac>
</target>
<!-- =================================================================== -->
<!-- S Q L T O X M L -->
<!-- =================================================================== -->
<!-- Create an xml schema from an sql schema. -->
<!-- -->
<!-- inputFile: The input sql file. This must be valid sql file but -->
<!-- it not not be in any specific format. -->
<!-- outputFile: The file where the xml schema will be written -->
<!-- =================================================================== -->
<target
name="project-sql2xml"
description="==> creates an xml schema from an sql schema">
<taskdef
name="sql-xml"
classname="org.apache.torque.task.TorqueSQLTransformTask">
<classpath refid="torque-classpath"/>
</taskdef>
<sql-xml
inputFile="schema/schema.sql"
outputFile="schema/schema.xml"
/>
</target>
<!-- ================================================================== -->
<!-- J A V A D O C -->
<!-- ================================================================== -->
<target
name="javadocs"
description="==> generates the API documentation">
<mkdir dir="${torque.home}/${outputDirectory}/javadoc"/>
<javadoc
sourcepath="${torque.home}/${outputDirectory}"
packagenames="${targetPackage}.*"
destdir="${outputDirectory}/javadoc"
author="true"
private="true"
version="true"
use="true">
<classpath refid="torque-classpath"/>
</javadoc>
</target>
<!-- =================================================================== -->
<!-- =================================================================== -->
<!-- O J B S T U F F -->
<!-- =================================================================== -->
<!-- =================================================================== -->
<target
name="project-ojb-repository">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating OJB repository |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="ojb-repository"
classname="org.apache.torque.task.TorqueDataModelTask">
<classpath refid="torque-classpath"/>
</taskdef>
<ojb-repository
contextProperties="${build.properties}"
controlTemplate="ojb/repository/Control.vm"
targetPackage="${targetPackage}.om"
targetDatabase="${database}"
outputDirectory="${torque.home}/${outputDirectory}/ojb"
templatePath="${templatePath}"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputFile="report.${project}.ojb.generation">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</ojb-repository>
</target>
<target
name="project-ojb-repository-classpath">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating OJB repository |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="ojb-repository"
classname="org.apache.torque.task.TorqueDataModelTask">
<classpath refid="torque-classpath"/>
</taskdef>
<ojb-repository
contextProperties="${build.properties}"
controlTemplate="ojb/repository/Control.vm"
targetPackage="${targetPackage}.om"
targetDatabase="${database}"
outputDirectory="${torque.home}/${outputDirectory}/ojb"
useClasspath="true"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputFile="report.${project}.ojb.generation">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</ojb-repository>
</target>
<target
name="project-ojb-model">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating OJB model |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="ojb-model"
classname="org.apache.torque.task.TorqueDataModelTask">
<classpath refid="torque-classpath"/>
</taskdef>
<ojb-model
contextProperties="${build.properties}"
controlTemplate="ojb/model/Control.vm"
targetPackage="${targetPackage}.om"
targetDatabase="${database}"
outputDirectory="${torque.home}/${outputDirectory}/ojb"
templatePath="${templatePath}"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputFile="report.${project}.ojb.generation">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</ojb-model>
</target>
<target
name="project-ojb-model-classpath">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating OJB model |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<taskdef
name="ojb-model"
classname="org.apache.torque.task.TorqueDataModelTask">
<classpath refid="torque-classpath"/>
</taskdef>
<ojb-model
contextProperties="${build.properties}"
controlTemplate="ojb/model/Control.vm"
targetPackage="${targetPackage}.om"
targetDatabase="${database}"
outputDirectory="${torque.home}/${outputDirectory}/ojb"
useClasspath="true"
sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
outputFile="report.${project}.ojb.generation">
<fileset dir="${torque.home}/${schemaDirectory}">
<include name="*-schema.xml"/>
</fileset>
</ojb-model>
</target>
</project>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>