ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcus Lindblom <>
Subject Attempting to write a custom import-task
Date Fri, 08 Sep 2006 11:53:58 GMT
(I couldn't find anything in the mail-archives, nor on google, on this, 
so I'm asking here. It's my first post to this list and I haven't 
subscribed it previously either.)

Hi all,

Short version: How to use <import> from a <scriptdef> custom task?

Long version:

I'm trying to make a custom import task that performs some path-finding 
& caching to locate other build-files, in a dependency-system that we've 
developed on top of ant with the help of a set of beanshell-description. 
(It allows various modules to refer to each others by name only, not via 
paths. ). It works quite nice and Ant is really awesome, etc etc. :-)

Until now, we've used <import file="${}"/> to import 
dependencies, which is run after importing our system-root-build.xml 
which runs a script that sets all these properties. However, if that 
module does not exists (not being checked out, misspelled, diretory 
moved) there is no good way to report for an error or rather, to rescan 
the directories for it (it should at least try that once per build.) So, 
I thought of making my own import (call it mod-import) that takes a 
'module' attribute and checks if the property is set, the build-file 
exists, etc etc, before actually importing the file stored in the property.

But I run in to problem with calling ant's import, as it is set to only 
be a top-level task, so calling project.create("import") from my 
custom-import task fails. Is there any way around that, or are there 
technical reasons for it to be so (rather than user-control issues)?

If my custom task could be defined to be a top-level task, which it is 
and should be checked to be, then it should be able to access other 
top-level tasks as well, no? (I don't know much about ant internals, so 
I may be going in the wrong direction here.)

All help warmly welcomed.


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

View raw message