ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Upayavira>
Subject Configuring a custom task
Date Tue, 29 Mar 2005 11:33:11 GMT
Hi all,

I have written my own task. Here's how a section of my build.xml might look:

<path id="my.classpath">
   <dirset dir="WEB-INF/classes"/>
   <fileset dir="WEB-INF/lib" includes="*.jar"/>
<taskdef name="my-chown" classname="com.blah.ant.ChangeOwnershipTask" 
<taskdef name="my-chmod" classname="com.blah.ant.ChangePermissionsTask" 

<target name="mytarget">
   <property name="my.config" value="file:WEB-INF/config/"/>
   <my-chown classpathref="my.classpath"

The task itself is stored in a different lib directory, not on Ant's own 
classpath. Now, this works, but it feels a bit clumsy. I therefore have 
two questions:

1) Every time I use my task, I have to pass the task the classpath 
definition, as the task needs to create a new classloader with which to 
run my application. Is there a way to remove the necessity to mention 
the classpath, deriving it from the one used within the <taskdef>?

2) The application that the task is invoking requires a system property 
to be set. So my task takes in a property 'config', and sets the system 
property before invoking the application. But again, this needs to be 
done every time. Is there (a) a way to set a system property once that 
will effect all tasks or (b) would someone recommend a specific way to 
provide this configuration just once, e.g. set a property, and have the 
task always look for a property of that name. Is there a convention here?

Thanks for any help you can provide.

Regards, Upayavira

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message