On Thu, 20 Nov 2003, Kollivakkam R. Raghavan wrote:

> Hi Thomas, 
> Can you please give me a specific pointer on where you call Ant tasks
> from within a program.  I use HSQL as my database and would find this
> really useful.
> Thanks in advance.
> Raghavan

I can't give you specific details on the torque tasks themselves since in
my unit tests I call the xdoclet ojb task not the torque tasks, but I give
you some suggestions:

First, you should create a ant build file that does what you want to
achieve via code, i.e. that uses torque to create and populate the
database. The reason for this is that this way you know which properties
are required and what values they should have.

Then you convert this build file to java code. Basically you instantiate
the task class (you have a taskdef for it in the build file except if its
an ant core task), set the attributes that you use in the build file
(these are bean properties in the corresponding java class meaning that
you have getter and setter methods for them), and then call setProject
with a new org.apache.tools.ant.Project object and finally execute on the
task object.
Slightly more tricky are sub tasks. For example, if the task you're
calling can work with filesets, then you create a new fileset object
(org.apache.tools.ant.types.FileSet class), set attributes on it
(e.g. destDir), and use setIncludes to set the files to include. After
that you use setFileset on the task object with your fileset object.

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to