[Pulling together a few responses]

On 2011-02-15, Mohan wrote:

> I'm not using any wrapper script for ant invocation. I'm invoking the
> ant script directly from Ant-1.8.2/bin/ant as shown in the second
> update.

"the ant script directly from Ant-1.8.2/bin/ant" is the wrapper script I
was talking about ;-)

This is not the problem as we've seen by now.  Your stripped-down
example really helped, thanks a lot.

> Are you able to reproduce the issue using the code snippet provided?

Yes, and it led to
<https://issues.apache.org/bugzilla/show_bug.cgi?id=50788>.

I'll investigate this further (but it will take a day or two until I get
there).

> Just to clarify, if I use getProject(), I'm not getting an error.  But
> I would like to create a new Project in the Obfuscate's execute method
> where I want to run my tasks.

I won't pretend I understand why you'd want to do that.

The project instance is your tasks liaison to all things Ant.  Your new
project instance will use default values for several things (like the
logger) and not know anything about the customizations your "real"
project instance has received.

Anyway, there are ways to use separate instances.

If your task wants to run in a subcontext where it can set properties
that are not visible to other tasks (like <ant> does for the child
project) then the static Project.createSubProject method is the one you
want to use.

If your really really really want to use "new Project()" you should make
sure it gets initialized properly by invoking the init() method on your
new instance before you call createTask.  This should load the default
task definitions and make your problem go away (I just checked and it
works).

Stefan

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

Reply via email to