ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew n marshall <>
Subject Re: Import task defined in other build file?
Date Wed, 05 Mar 2008 19:33:02 GMT

Doh...  Had the answer in the first word of my subject line.  Thanks Peter.

But the idea of importing the entire file seems very messy.  I was 
hoping there would be a way I could import the effect of the new task 
definition without all the targets and properties that define it.  
Because of the potential for naming conflicts when using import, I have 
to prefix all the target names.

This is especially annoying in the example I show below.  My project 
uses cpptasks. And because there is no official release, I'm using 
svnant to keep cpptasks updated.  If I use import for this, the runtime 
namespace of my project build file contains all these other properties 
and targets that have little to do with my own project, each of which 
need to prefix to avoid namespace collision.

So... instead of...
   ant -f svnant.xml update
I end up with
   ant -f svnant.xml svnant_update
which seems a little redundant.  Same goes for all the clean, compile, 
etc. targets of the svnant.xml and cpptasks.xml build files.

So let me clarify my question:
  Is there anyway to define a new task using a target in another build 
file WITHOUT importing all the targets and properties of that buildfile?

Or do I just need to suck it up for the moment and accept the naming 

Thanks in advance.


Peter Reilly wrote:
> Use <import> and not <ant>
> Peter
> On Wed, Mar 5, 2008 at 1:46 PM, Andrew n marshall wrote:
>>  Is it possible to define a task in one ant build file, but use it in
>>  another?  For example, I want to have a single build file that contains
>>  the properties and tasks to download a copy of svnant and define its
>>  tasks.  Then I want to call that ant file's define_svn_task target from
>>  another file (which works) and call an <svn ../> task, like this:
>>   <ant antfile="svnant.xml" target="define_svn_task"/><!-- which calls taskdef
>>   <svn>
>>     <checkout url="${cpptasks.svn}" destPath="${cpptasks.dir}" />
>>   </svn>
>>  Thus, I can copy this svnant.xml to several projects and repositories
>>  without having to edit out project specific details or dig for svnant
>>  attributes like the download URL or install directory.
>>  When I tried this, the define_svn_task target succeeded, but it "failed
>>  to create task or type svn" in the next line.
>>  Can someone provide an example of how to do this properly?
>>  Anm

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

View raw message