On 2008-12-11, Raja Nagendra Kumar <nagendra.r...@tejasoft.com> wrote:

> Based on lifecycle link you provided I see that there is a mention
> of

>> The task gets references to its project and location inside the
>> buildfile via its inherited project and location variables.

> In such cases, why should the user initialise them explicitly, when
> run from build file.

Because Ant can only intialize task it creates itself.

> Pl. suggest any other better approach, so that, when the user does not
> explicitly intialise the task, it could take parents project and other info
> related to parent.

That would be the wrong approach.  The user is responsible for
lifecycle handling when he creates tasks manually IMHO.  If your
method was changed to read

private final Copy createCopyTask()
    {
        final Copy c = new Copy();
+       c.bindToOwner(this);
+       c.init();
        c.setTodir(new File(getDestdir().getPath()));
        c.setIncludeEmptyDirs(false);
        c.setFailOnError(true);
        c.setOverwrite(false);
        c.setFlatten(false);
        return c;
    }

things should work as expected.

Ant really is not a general purpose API, if we wanted to make it one,
we'd have bigger problems than providing default project instances.
We shouldn't pretend it is one.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to