You have got to set the location and the target attributes of
the import task, in ant 1.7 there is a utility method bindToTask
to do this.
However, you are using beanshell, so an easier method would be
to extend the import class itself:
On 9/8/06, Marcus Lindblom wrote:
> (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 from a 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 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
> 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: firstname.lastname@example.org
> For additional commands, e-mail: email@example.com