ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raja Nagendra Kumar <Nagendra.R...@tejasoft.com>
Subject Re: Project vs Sub Project - Why such Design
Date Thu, 05 Nov 2009 12:01:42 GMT

>For a task inside the called build file, getProject will not return the
>parent but the current project.

Stefan, we are using Ant class with in a custom task and see that
getProject() is returning the parents context.

I went though the code and find that lot of initialisation is done with in
the execute() method, which may be the reason for such behavior. May be this
could be relooked.. or there is some thing wrong with our Ant object
creating and preparation.

Ant lAnt = new Ant();
lAnt.bindToOwner(currentTask);
lAnt.setTaskName(currentTask.getTaskName());
lAnt.init();
lAnt.setDir(createFile(aDir));
lAnt.setInheritAll(false);
lAnt.setInheritRefs(false);
//lAnt.getProject() - when we call getProject() here.. it gives parent one.. 
lAnt.execute(); 

//due to few internal initalisations with in execute some where getProject()
may be changing so that subproject would see getNewproject() value.. but not
sure how such things are needed to be done with the custom task code..
however in xml script every thing is working fine.

> Why did ant decide to with sub project approach rather than calling each
> ant
> call as independent project by it self but it may have just one parent.

Trying to understand why subproject was introduced with Ant.java.. it would
have very well been a new independent project it self. What are we gaining
as subproject and keeping its relation with parent project.  Due to
protected nature of getNewProject(), we had to go with inheritance of Ant
and define a new class.

Pl. understand that all my comments w.r.t to writing of Custom tasks.

Regards,
Nagendra

Stefan Bodewig wrote:
> 
> On 2009-11-05, Raja Nagendra Kumar <Nagendra.Raja@tejasoft.com> wrote:
> 
>> I see a protected method getNewProject()
> 
>> The sub project getProject() seems to give the value of parent project..
> 
> Both is inside the <ant> task?
> 
> <ant> is the task that creates the subproject (using getNewProject) and
> executes the targets inside of it.  The task itself is in the calling
> project and thus getProject returns the parent project (like it does for
> any other task in that project as well).
> 
> For a task inside the called build file, getProject will not return the
> parent but the current project.
> 
>> What is the senario
> 
>> A.xml -> calls B.xml --> c.xml
> 
>> When c.xml is called, is c the sub project of B and also A..
> 
> c is a sub project of B, yes.
> 
>> Why did ant decide to with sub project approach rather than calling each
>> ant
>> call as independent project by it self but it may have just one parent.
> 
> I don't think I understand the question.  Are you asking why c is not a
> sub project of A instead of B?  Why should it?  If B.xml contains an
> <ant> task invoking c.xml the build file writer of B.xml will certainly
> expect that B.xml will be the parent.  B.xml could be invoked directly
> from the command line rather than via an <ant> task in any other build
> file after all.
> 
>> I am sure this must be having some thing to do with class loaders,
>> parallelization etc..
> 
> Not at all.
> 
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Project-vs-Sub-Project---Why-such-Design-tp26208567p26212468.html
Sent from the Ant - Dev mailing list archive at Nabble.com.


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


Mime
View raw message