ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elankath, Tarun (Cognizant)" <ETa...@blr.cognizant.com>
Subject RE: Problem with Ant Automation using Ant API
Date Mon, 18 Nov 2002 11:56:16 GMT
Thanks,
	That worked indeed. But that doesn't stop project from loading
everything again.
I suppose I need to create a new Project everytime and configure it.

I guess the Project object was never designed with the thought that it may
be kept around for re-use after a target was done executing.

Cheers,
Tarun

-----Original Message-----
From: PREMKUMAR, N [AG/8042] [mailto:n.premkumar@monsanto.com]
Sent: Monday, November 18, 2002 4:15 PM
To: 'Ant Users List'
Subject: RE: Problem with Ant Automation using Ant API


Try using 

Project.addOrReplaceTarget( java.lang.String myTargetName,Target myTarget)
followed by
Project.executeTarget(myTargetname)

Prem

-----Original Message-----
From: Elankath, Tarun (Cognizant) [mailto:ETarun@blr.cognizant.com]
Sent: Monday, 18 November 2002 4:13 PM
To: ant-user@jakarta.apache.org
Subject: Problem with Ant Automation using Ant API


Hi all,

I have developed a GUI tool that makes use of the Ant API and an existing
build.xml file for our project.
(Targets are represented as "icons" on the toolbar)

As soon as the GUI application starts up, it creates a new Project object
and configures it with an existing build file and keeps the project object
as an instance variable called 'project'

Whenever an icon on the toolbar is clicked, the statement
"Project.executeTarget(targetname)" gets executed (in a separate thread).
The problem is that whenever the same target icon is clicked a second time,
it fails with the error "Duplicate target".

This is because for some reason, the project object loads all the default
tasks and definitions once again from the build.xml file, thus coming across
the all the targets once again (which were already loaded during startup).

My question is this:
Is there anyway to prevent Project from loading all tasks and defitions
repeatedly from the build file ?
If not I guess the only alternative is to create a new Project object
everytime a target is clicked on, call ProjectHelper.configureProject(), and
then call executeTarget() on the new project object.  This way seems
wasteful to do everytime.


All help/pointers appreciated,
Tarun


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

Mime
View raw message