You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Trever Shick <ts...@seqtek.com> on 2004/02/26 16:35:31 UTC

Question about setup (quick)

Question about setup.

I've got torque running with very little problem. However I don't care 
to have a bunch of torque files in my project that are used for 
generation ( a tool basically ).

So here's what I did:

I have two projects torque-gen (which is just the torque-gen.jar 
expanded) and then I have my "torque-test" project".

torque-gen/
    lib/
    templates/
    build-torque.xml
    build.properties
    *.properties

torque-test/
    schema/test-schema.xml
    lib/(torque runtime libs)
    db/test-schema.sql
    build.properties

My torque-test/build.properties contains:
    torque.java.dir = ../torque-test/src-generated
    torque.sql.dir = ../torque-test/db
    torque.schema.dir = ../torque-test/schema
    torque.doc.dir = ../torque-test/doc
    torque.javadoc.dir = ../torque-test/javadoc

Then, to run the ant build on torque-build.xml I run (in torque-test):
ant -f ../torque-gen/torque-build.xml -propertyfile build.properties

This all seems to work very well and really splits the torque generation 
tool from my actual project code base.

Does anyone see any major flaws with this?  Has anyone else done this 
with success?

Thanks






-- 

Trever M. Shick


Sequoyah Technologies
2448 East 81st Street, Suite 2500
Tulsa, OK  74137

tshick@seqtek.com

CONFIDENTIALITY NOTE:   The information contained in this document and accompanying documents is legally privileged and confidential information intended only for the use of the individual or entity named herein.  If the reader of this transmittal is not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copy of this information is strictly prohibited.  If you have received this transmittal and accompanying information in error, please immediately notify us by telephone and return the original document and accompanying information to us at the address above and destroy any copies received.  Thank You! 



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: Question about setup (quick)

Posted by Brent Atkins <Br...@Pro-Sys.biz>.
I guessing this works for you, but there are a few other ways that it can be done.

Unless you are using your own custom templates you don't really need to expand the torque-gen.jar,
you can just put it as a lib under torque-test and it should run.  I'm guessing that you didn't do
this because you don't want torque-gen.jar to be deployed with your application (why would you?).

In this case I would recommend that you switch your build from using ant to the Maven plug-in.  I
have recently set this up and found it to be a really nice addition to my project.  It keeps me from
having to keep the libs stored in CVS as well as it gives me the option to set what libs are used
during compile time and which libs are actually deployed.

You can reuse all of your existing ant tasks with Maven just fine.  Of course if you are upset about
the lack of decent docs for Torque, you will probably hate Maven too :-).  Once you get it setup
properly (in my experience it required a change to the Torque-plugin as well as a couple of
non-documented project.properties settings - check the archive, I've posted all of this in the last
couple weeks) you can run it all by typing [maven torque] which will generate all of your code.  The
nice thing about this is I only have the schema in my CVS, all of the rest is handled by Maven.

Ok, I have a couple custom goals (what Maven calls an ant target) in maven.xml that let me update my
database without losing any data in it and stuff like that, but this isn't deployed either so what
do I care?

And once you run [maven site] you will wonder how you ever did without it.

In case you are still intent on using ant, here are the relevant snippets of my ant build.xml that I
used previously.

<target name="help">
   <echo message="--------------------- Torque Build Options ------------------------------------"/>
   <echo message="  torque......Runs the buildfile torque/build-torque.xml"/>
   <echo message="                does NOT create database"/>
   <echo message="  db-replace......Runs the buildfile torque/build.torque.xml"/>
   <echo message="                and runs SQL insert statements - ERASES EXISTING DB"/>
   <echo message="  db-upgrade......Runs the buildfile torque/build_torque.xml"/>
   <echo message="                and runs SQL insert statements - SAVES EXISTING DB"/>
</target>

<!-- ==================== "torque" Target ===================================-->

    <!--
          This executes the "main" target in build-torque.xml
    -->

  <target name="torque" depends="init">
    <ant antfile="build-torque.xml" target="main"/>
  </target>

<!-- ==================== "db-replace" Target ============================== -->

    <!--
          This target executes the "create-db" and "insert-sql"
          target in the build-torque.xml
    -->

  <target name="db-replace" depends="torque">
    <ant antfile="build-torque.xml" target="create-db"/>
    <ant antfile="build-torque.xml" target="insert-sql"/>
  </target>

<!-- ==================== "db-upgrade" Target ============================== -->

    <!--
          This target executes the "create-db" and "insert-sql"
          target in the build-torque.xml after creating a dump of
          the existing database, then it imports the backup.sql
          backinto the database.
    -->

  <target name="db-upgrade" depends="torque">
  <!--
      Begin by backing up existing database
      NOTE: Currently only used for Linux
          Add your own OS as needed and commit
  -->
    <echo message="Backing up database"/>
    <exec executable="/bin/sh" os="Linux">
    <arg value="-c"/>
    <arg value="mysqldump --add-locks --quick --flush-logs --lock-tables
      --no-create-info -u ${torque.database.user} -p${torque.database.password}
       ${app.name} > ${app.home}/btp.backup.sql"/>
    </exec>
  <!--
      Execute the "create-db and "insert-sql"
      target in the build-torque.xml
  -->
    <ant antfile="build-torque.xml" target="create-db"/>
    <ant antfile="build-torque.xml" target="insert-sql"/>
  <!--
      Restore saved database
  -->
    <echo message="Restoring database"/>
    <sql
      driver="${torque.database.driver}"
      url="${torque.database.url}"
      userid="${torque.database.user}"
      password="${torque.database.password}"
      src="${app.home}/btp.backup.sql"
    />
  <!--
      Clean up after yourself
  -->
    <delete file="${app.home}/btp.backup.sql" quiet="true"/>
  </target>

I still had to have build-torque.xml and build.properties had to have this...

# torque properties required to build
# you should change these to match your
# system settings

torque.database.user=foo
torque.database.password=bar

# torque properties required to build
# you should not have to change these

torque.home=.
torque.java.dir=${torque.home}/src
torque.useClasspath=true
torque.project=btp
torque.database=mysql
torque.targetPackage=btp.torque
torque.database.host=127.0.0.1
torque.database.createUrl=jdbc:mysql://127.0.0.1/mysql
torque.database.buildUrl=jdbc:mysql://127.0.0.1/btp
torque.database.url=jdbc:mysql://127.0.0.1/btp
torque.database.driver=com.mysql.jdbc.Driver

Good luck!

-----Original Message-----
From: Trever Shick [mailto:tshick@seqtek.com]
Sent: Thursday, February 26, 2004 10:36 AM
To: torque-user@db.apache.org
Subject: Question about setup (quick)


Question about setup.

I've got torque running with very little problem. However I don't care
to have a bunch of torque files in my project that are used for
generation ( a tool basically ).

So here's what I did:

I have two projects torque-gen (which is just the torque-gen.jar
expanded) and then I have my "torque-test" project".

torque-gen/
    lib/
    templates/
    build-torque.xml
    build.properties
    *.properties

torque-test/
    schema/test-schema.xml
    lib/(torque runtime libs)
    db/test-schema.sql
    build.properties

My torque-test/build.properties contains:
    torque.java.dir = ../torque-test/src-generated
    torque.sql.dir = ../torque-test/db
    torque.schema.dir = ../torque-test/schema
    torque.doc.dir = ../torque-test/doc
    torque.javadoc.dir = ../torque-test/javadoc

Then, to run the ant build on torque-build.xml I run (in torque-test):
ant -f ../torque-gen/torque-build.xml -propertyfile build.properties

This all seems to work very well and really splits the torque generation
tool from my actual project code base.

Does anyone see any major flaws with this?  Has anyone else done this
with success?

Thanks






--

Trever M. Shick


Sequoyah Technologies
2448 East 81st Street, Suite 2500
Tulsa, OK  74137

tshick@seqtek.com

CONFIDENTIALITY NOTE:   The information contained in this document and accompanying documents is
legally privileged and confidential information intended only for the use of the individual or
entity named herein.  If the reader of this transmittal is not the intended recipient, you are
hereby notified that any use, dissemination, distribution, or copy of this information is strictly
prohibited.  If you have received this transmittal and accompanying information in error, please
immediately notify us by telephone and return the original document and accompanying information to
us at the address above and destroy any copies received.  Thank You!



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org