However, to make things 100% maven friendly (to get rid of the contextProperties setting and loading properties from file), we need to pass the variables from JellyContext to VelocityContext. I figured out that I can get those from JellyContext.getVariables() (returns Map), but now I need a way to populate these into the ExtendedProperties that the Ant tasks build.
I'll send some patches soon ;-)
Rgds,
Neeme
Quinton McCombs ::
I was hoping this would be the case. I am about 80% complete now....-----Original Message-----
From: Scott Eade [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 19, 2003 2:29 PM
To: Torque Developers List
Subject: Re: Converting build-torque.xml to jelly script
I agree +1.
On 20/02/2003 5:53 AM, "Quinton McCombs" <[EMAIL PROTECTED]> wrote:
Any reason not to use a jelly script for the torque plugininstead of
calling the ant build file? This would allow us tocompletely do away
with the torque.jar and torque.lib settings.....--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
# -------------------------------------------------------------------
# P L U G I N P R O P E R T I E S
# -------------------------------------------------------------------
# Torque plugin
# -------------------------------------------------------------------
# Note: lib.dir/torque.lib.dir and build.properties/
# torque.contextProperties are set manually in the build-torque.xml
# file as they need to be defined before this file can be loaded from
# the classpath.
#
# Old properties that are commented out are just place holders to
# help organize things.
# -------------------------------------------------------------------
# -------------------------------------------------------------------
#
# B A S I C P R O P E R T I E S
#
# -------------------------------------------------------------------
torque.home = .
torque.project = need to override this!
torque.database = postgresql
torque.targetPackage = org.apache.torque
torque.runOnlyOnSchemaChange = true
# -------------------------------------------------------------------
#
# D I R E C T O R I E S
#
# -------------------------------------------------------------------
torque.output.dir = ${torque.home}/src
torque.schema.dir = ${torque.home}/schema
torque.templatePath = templates
torque.useClasspath = true
torque.doc.dir = ${torque.output.dir}/doc
torque.java.dir = ${torque.output.dir}/java
torque.javadoc.dir = ${torque.output.dir}/javadoc
torque.ojb.dir = ${torque.output.dir}/ojb
torque.sql.dir = ${torque.output.dir}/sql
torque.omzip.dir = ${torque.output.dir}
# -------------------------------------------------------------------
#
# D A T A B A S E S E T T I N G S
#
# -------------------------------------------------------------------
torque.database.createUrl = jdbc:postgresql://127.0.0.1:5432/template1
torque.database.buildUrl = jdbc:postgresql://127.0.0.1:5432/bookstore
torque.database.url = jdbc:postgresql://127.0.0.1:5432/bookstore
torque.database.driver = org.postgresql.Driver
torque.database.user = postgres
torque.database.password =
torque.database.host = 127.0.0.1
torque.database.schema =
torque.database.name =
torque.database.manualCreation = false
torque.saveJavaName = false
# -------------------------------------------------------------------
#
# T E M P L A T E V A R I A B L E S
#
# -------------------------------------------------------------------
torque.addGetByNameMethod = true
torque.addIntakeRetrievable = false
torque.retrievableInterface = org.apache.turbine.om.Retrievable
torque.addSaveMethod = true
torque.addTimeStamp = true
torque.basePrefix = Base
torque.complexObjectModel = true
torque.saveException = Exception
torque.useClasspath = true
torque.useManagers = false
torque.omzip.src.base = false
torque.omzip.src.extension = false
torque.omzip.bin.base = false
torque.omzip.bin.extension = false
torque.omzip.deleteFiles = false
torque.generateDeprecated = true
# -------------------------------------------------------------------
#
# M I S C . S E T T I N G S
#
# -------------------------------------------------------------------
torque.idTableXMLFile =
torque.doc.format = html
torque.doc.html.normalFont = font-family: Verdana; font-size: 10pt;
torque.doc.html.fkColor = afe295
torque.initialID = 1001
# -------------------------------------------------------------------
#
# C O N T R O L T E M P L A T E S
#
# -------------------------------------------------------------------
torque.template.sql = sql/base/Control.vm
torque.template.om = om/Control.vm
torque.template.idTable = sql/id-table/Control.vm
torque.template.dataDtd = data/Control.vm
torque.template.dataDump = data/dump/Control.vm
torque.template.dataSql = sql/load/Control.vm
torque.template.doc = doc/Control.vm
torque.template.sqlDbInit = sql/db-init/Control.vm
torque.template.ojb = ojb/repository/Control.vm
torque.template.ojbModel = ojb/model/Control.vm
# -------------------------------------------------------------------
#
# C O M P I L E S E T T I N G S
#
# -------------------------------------------------------------------
torque.compile.src.dir = ${torque.java.dir}
torque.compile.build.dir = bin/classes
torque.compile.debug = on
torque.compile.deprecation = off
torque.compile.optimize = off
# -------------------------------------------------------------------
#
# I N C L U D E A N D E X C L U D E S E T T I N G S
#
# -------------------------------------------------------------------
torque.schema.sql.includes = *-schema.xml
torque.schema.sql.excludes =
torque.schema.doc.includes = *-schema.xml
torque.schema.doc.excludes =
torque.schema.create-db.includes = *-schema.xml
torque.schema.create-db.excludes =
torque.schema.init-sql.includes = *-schema.xml
torque.schema.init-sql.excludes = id-table-schema.xml
torque.schema.om.includes = *-schema.xml
torque.schema.om.excludes = id-table-schema.xml
torque.schema.ojb.includes = *-schema.xml
torque.schema.ojb.excludes =
<?xml version="1.0"?>
<project xmlns:j="jelly:core">
<property name="build.properties" value="build.properties"/>
<property name="torque.contextProperties" value="${build.properties}"/>
<!--
<property name="build.properties" value="torque-build.properties"/>
<property name="torque.contextProperties" value="${build.properties}"/>
<property file="${torque.contextProperties}"/>
<path id="torque-classpath">
<path refid="maven.dependency.classpath"/>
</path>
<property resource="org/apache/torque/default.properties">
<classpath>
<path refid="torque-classpath"/>
</classpath>
</property>
-->
<!--
Do forward declarations of all of our tasks to
centralize them and clean up the targets.
-->
<taskdef name="torque-data-model" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.TorqueDataModelTask"/>
<taskdef name="torque-data-dump" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.TorqueDataDumpTask"/>
<taskdef name="torque-data-sql" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.TorqueDataSQLTask"/>
<taskdef name="torque-doc" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.TorqueDocumentationTask"/>
<taskdef name="torque-jdbc-transform" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.TorqueJDBCTransformTask"/>
<taskdef name="torque-package-to-path" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.PackageAsPathTask"/>
<taskdef name="torque-sql" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.TorqueSQLTask"/>
<taskdef name="torque-sql-exec" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.TorqueSQLExec"/>
<taskdef name="torque-sql-transform" classpathref="maven.dependency.classpath" classname="org.apache.torque.task.TorqueSQLTransformTask"/>
<!-- ================================================================ -->
<!-- M A I N G O A L -->
<!-- ================================================================ -->
<!-- This default goal will run all the targets that generate -->
<!-- source. You will probably only run this goal once then -->
<!-- call individual goals as necessary to update your sources -->
<!-- when you change your XML schema. -->
<!-- ================================================================ -->
<goal name="torque" description="alias for torque:main" prereqs="torque:main"/>
<goal name="torque:main" description="==> generates sql + om classes">
<attainGoal name="torque:sql"/>
<attainGoal name="torque:om"/>
</goal>
<!-- ================================================================ -->
<!-- C H E C K U S E C L A S S P A T H -->
<!-- ================================================================ -->
<!-- Temporary hack around the propertiesUtil bug. Should -->
<!-- be fixed soon. -->
<!-- ================================================================ -->
<goal name="torque:check-use-classpath">
<condition property="torque.internal.useClasspath">
<equals arg1="${torque.useClasspath}" arg2="true"/>
</condition>
</goal>
<!-- ================================================================ -->
<!-- C H E C K R U N O N L Y O N S C H E M A C H A N G E -->
<!-- ================================================================ -->
<!-- Maps the torque.runOnlyOnSchemaChange to -->
<!-- torque.internal.runOnlyOnSchemaChange -->
<!-- ================================================================ -->
<goal name="torque:check-run-only-on-schema-change">
<condition property="torque.internal.runOnlyOnSchemaChange">
<equals arg1="${torque.runOnlyOnSchemaChange}" arg2="true"/>
</condition>
</goal>
<!-- ================================================================ -->
<!-- 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 Torque tables! The tables you require for your -->
<!-- project should be specified in project-schema.xml. -->
<!-- ================================================================ -->
<goal name="torque:sql" prereqs="torque:check-use-classpath, torque:check-run-only-on-schema-change" description="==> generates the SQL for your project">
<uptodate property="torque.internal.sql.uptodate" targetfile="${torque.sql.dir}/${torque.project}-schema.sql">
<srcfiles dir="${torque.schema.dir}" includes="**/*-schema.xml"/>
</uptodate>
<j:if test="${!torque.internal.sql.uptodate || !torque.internal.runOnlyOnSchemaChange}">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating SQL for YOUR Torque project! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<j:choose>
<j:when test="${torque.internal.useClasspath}">
<attainGoal name="torque:sql-classpath"/>
</j:when>
<j:otherwise>
<attainGoal name="torque:sql-template"/>
</j:otherwise>
</j:choose>
</j:if>
</goal>
<goal name="torque:sql-classpath">
<torque-sql
basePathToDbProps="sql/base/"
controlTemplate="${torque.template.sql}"
idTableXMLFile="${torque.idTableXMLFile}"
outputDirectory="${torque.sql.dir}"
outputFile="report.${torque.project}.sql.generation"
sqldbmap="${torque.sql.dir}/sqldb.map"
targetDatabase="${torque.database}"
useClasspath="${torque.useClasspath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.sql.includes}" excludes="${torque.schema.sql.excludes}"/>
</torque-sql>
</goal>
<goal name="torque:sql-template">
<torque-sql
basePathToDbProps="sql/base/"
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.sql}"
idTableXMLFile="${torque.idTableXMLFile}"
outputDirectory="${torque.sql.dir}"
outputFile="report.${torque.project}.sql.generation"
sqldbmap="${torque.sql.dir}/sqldb.map"
targetDatabase="${torque.database}"
templatePath="${torque.templatePath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.sql.includes}" excludes="${torque.schema.sql.excludes}"/>
</torque-sql>
</goal>
<!-- ================================================================ -->
<!-- G E N E R A T E D O C S -->
<!-- ================================================================ -->
<!-- Generates documentation to -->
<!-- ${torque.doc.dir}/project-schema.html -->
<!-- ================================================================ -->
<goal name="torque: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="+------------------------------------------+"/>
<torque-doc
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.doc}"
outputDirectory="${torque.doc.dir}"
outputFile="report.${torque.project}.doc.generation"
outputFormat="${torque.doc.format}"
sqldbmap="${torque.sql.dir}/sqldb.map"
templatePath="${torque.templatePath}"
useClasspath="${torque.useClasspath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.doc.includes}" excludes="${torque.schema.doc.excludes}"/>
</torque-doc>
</goal>
<!-- ================================================================ -->
<!-- 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. -->
<!-- ================================================================ -->
<goal name="torque:create-db" description="==> generates the target database">
<condition property="torque.internal.manualCreation">
<equals arg1="${torque.database.manualCreation}" arg2="true"/>
</condition>
<j:if test="${torque.internal.manualCreation != 'true'}">
<torque-data-model
controlTemplate="${torque.template.sqlDbInit}"
outputDirectory="${torque.sql.dir}"
outputFile="create-db.sql"
targetDatabase="${torque.database}"
templatePath="${torque.templatePath}"
useClasspath="${torque.useClasspath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.create-db.includes}" excludes="${torque.schema.create-db.excludes}"/>
</torque-data-model>
<echo> Executing the create-db.sql script...</echo>
<sql
autocommit="true"
driver="${torque.database.driver}"
onerror="continue"
password="${torque.database.password}"
src="${torque.sql.dir}/create-db.sql"
url="${torque.database.createUrl}"
userid="${torque.database.user}">
<classpath refid="maven.dependency.classpath"/>
</sql>
</j:if>
</goal>
<!-- ================================================================ -->
<!-- I N S E R T S I N G L E S Q L F I L E S -->
<!-- ================================================================ -->
<goal name="torque:insert-sql" description="==> inserts the generated sql ">
<torque-sql-exec
autocommit="true"
driver="${torque.database.driver}"
onerror="continue"
password="${torque.database.password}"
sqldbmap="${torque.sql.dir}/sqldb.map"
srcDir="${torque.sql.dir}"
url="${torque.database.buildUrl}"
userid="${torque.database.user}">
<classpath refid="maven.dependency.classpath"/>
</torque-sql-exec>
</goal>
<!-- ================================================================ -->
<!-- J D B C TO X M L -->
<!-- ================================================================ -->
<goal name="torque:jdbc" description="==> jdbc to xml">
<echo message="+-----------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating XML from JDBC connection ! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+-----------------------------------------------+"/>
<torque-jdbc-transform
dbDriver="${torque.database.driver}"
dbPassword="${torque.database.password}"
dbSchema="${torque.database.schema}"
dbUrl="${torque.database.url}"
dbUser="${torque.database.user}"
outputFile="${torque.schema.dir}/schema.xml"
sameJavaName="${torque.sameJavaName}"/>
</goal>
<!-- ================================================================ -->
<!-- Generate SQL from XML data file -->
<!-- ================================================================ -->
<goal name="torque: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="+-----------------------------------------------+"/>
<torque-data-sql
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.dataSql}"
dataDTD="${torque.schema.dir}/${torque.project}-data.dtd"
dataXmlFile="${torque.schema.dir}/${torque.project}-data.xml"
outputDirectory="${torque.output.dir}"
outputFile="${torque.project}-data.sql"
sqldbmap="${torque.sql.dir}/sqldb.map"
targetDatabase="${torque.database}"
templatePath="${torque.templatePath}"
useClasspath="${torque.useClasspath}"
xmlFile="${torque.schema.dir}/${torque.project}-schema.xml"/>
</goal>
<!-- ================================================================ -->
<!-- G E N E R A T E I D B R O K E R I N I T S Q L -->
<!-- ================================================================ -->
<goal name="torque:id-table-init-sql" description="==> generates initialization sql for ID Broker">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating initialization SQL |"/>
<echo message="| for ID Broker system! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<torque-sql
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.idTable}"
outputDirectory="${torque.sql.dir}"
outputFile="report.idtable-init.sql.generation"
sqldbmap="${torque.sql.dir}/sqldb.map"
suffix="-idtable-init"
targetDatabase="${torque.database}"
templatePath="${torque.templatePath}"
useClasspath="${torque.useClasspath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.init-sql.includes}" excludes="${torque.schema.init-sql.excludes}"/>
</torque-sql>
</goal>
<!-- ================================================================ -->
<!-- Dump data from database into xml file -->
<!-- ================================================================ -->
<goal name="torque: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="+-----------------------------------------------+"/>
<torque-data-dump
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.dataDump}"
databaseDriver="${torque.database.driver}"
databaseName="${torque.database.name}"
databaseUrl="${torque.database.url}"
databaseUser="${torque.database.user}"
databasePassword="${torque.database.password}"
outputDirectory="${torque.output.dir}"
outputFile="report.${torque.project}.datadump.generation"
templatePath="${torque.templatePath}"
useClasspath="${torque.useClasspath}"
xmlFile="${torque.schema.dir}/${torque.project}-schema.xml"/>
</goal>
<!-- ================================================================ -->
<!-- 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 -->
<!-- ================================================================ -->
<goal name="torque:datadtd" description="==> generates the DATA DTD for your project">
<echo message="+-----------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating Data DTD for YOUR Torque project! |"/>
<echo message="| Woo hoo! |"/>
<echo message="| |"/>
<echo message="+-----------------------------------------------+"/>
<torque-data-model
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.dataDtd}"
outputDirectory="${torque.output.dir}"
outputFile="report.${torque.project}.datadtd.generation"
templatePath="${torque.templatePath}"
useClasspath="${torque.useClasspath}"
xmlFile="${torque.schema.dir}/${torque.project}-schema.xml"/>
</goal>
<!-- ================================================================ -->
<!-- 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 Torque OM! -->
<!-- ================================================================ -->
<goal name="torque:om" prereqs="torque:check-use-classpath" description="==> generates the Peer-based object model for your project">
<uptodate property="torque.internal.om.uptodate" targetfile="${torque.java.dir}/report.${torque.project}.om.generation">
<srcfiles dir="${torque.schema.dir}" includes="**/*-schema.xml"/>
</uptodate>
<j:if test="${!torque.internal.om.uptodate || !torque.internal.runOnlyOnSchemaChange}">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating Peer-based Object Model for |"/>
<echo message="| YOUR Torque project! Woo hoo! |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<j:choose>
<j:when test="${torque.internal.useClasspath}">
<attainGoal name="torque:om-classpath"/>
</j:when>
<j:otherwise>
<attainGoal name="torque:om-template"/>
</j:otherwise>
</j:choose>
<!-- antcall target="zip-base-om"/ -->
</j:if>
</goal>
<goal name="torque:om-classpath">
<torque-data-model
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.om}"
outputDirectory="${torque.java.dir}"
outputFile="report.${torque.project}.om.generation"
targetDatabase="${torque.database}"
targetPackage="${torque.targetPackage}"
useClasspath="${torque.useClasspath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.om.includes}" excludes="${torque.schema.om.excludes}"/>
</torque-data-model>
</goal>
<goal name="torque:om-template">
<torque-data-model
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.om}"
outputDirectory="${torque.java.dir}"
outputFile="report.${torque.project}.om.generation"
targetDatabase="${torque.database}"
targetPackage="${torque.targetPackage}"
templatePath="${torque.templatePath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.om.includes}" excludes="${torque.schema.om.excludes}"/>
</torque-data-model>
</goal>
<!-- =================================================================== -->
<!-- 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 -->
<!-- =================================================================== -->
<goal name="torque:sql2xml" description="==> creates an xml schema from an sql schema">
<torque-sql-transform inputFile="${torque.schema.dir}/schema.sql" outputFile="${torque.schema.dir}/schema.xml"/>
</goal>
<!-- =================================================================== -->
<!-- O J B S T U F F -->
<!-- =================================================================== -->
<goal name="torque:ojb" description="==> generates the repository and om for ojb (experimental)">
<attainGoal name="torque:ojb-repository"/>
<attainGoal name="torque:ojb-model"/>
</goal>
<goal name="torque:ojb-repository" description="==> generates the repository for ojb (experimental)">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating OJB repository |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<torque-data-model
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.ojb}"
targetDatabase="${torque.database}"
targetPackage="${torque.targetPackage}"
outputDirectory="${torque.ojb.dir}"
outputFile="report.${torque.project}.ojb.generation"
sqldbmap="${torque.sql.dir}/sqldb.map"
templatePath="${torque.templatePath}"
useClasspath="${torque.useClasspath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.ojb.includes}" excludes="${torque.schema.ojb.excludes}"/>
</torque-data-model>
</goal>
<goal name="torque:ojb-model" description="==> generates an object model for ojb (experimental)">
<echo message="+------------------------------------------+"/>
<echo message="| |"/>
<echo message="| Generating OJB model |"/>
<echo message="| |"/>
<echo message="+------------------------------------------+"/>
<torque-data-model
contextProperties="${torque.contextProperties}"
controlTemplate="${torque.template.ojbModel}"
targetDatabase="${torque.database}"
targetPackage="${torque.targetPackage}"
outputDirectory="${torque.ojb.dir}"
outputFile="report.${torque.project}.ojb.generation"
sqldbmap="${torque.sql.dir}/sqldb.map"
templatePath="${torque.templatePath}"
useClasspath="${torque.useClasspath}">
<fileset dir="${torque.schema.dir}" includes="${torque.schema.ojb.includes}" excludes="${torque.schema.ojb.excludes}"/>
</torque-data-model>
</goal>
</project>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
