You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Panayotis Katsaloulis <pa...@panayotis.com> on 2011/02/24 11:11:29 UTC

How to get the stack of targets, from inside a task?

Hello people!

I am trying to develop a custom ant task, which ideally would like to get hold of the stack of all parent targets.
For example in this  configuration:

<target name="one" depends="two,three"/>

<target name="two"/>

<target name="three" depends="four"/>

<target name="four">
	<customtask />
</target>


if the command "ant one" was executed from the command line, I'd like to get a list like this (in the task customtask):
one, three, four

In the documentation I found only the method getOwningTarget() which would only return the current target, "four".

Is there any way to do this?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How to get the stack of targets, from inside a task?

Posted by "Scot P. Floess" <sf...@nc.rr.com>.
No worries at all - I get it now...

I'd have to agree with you...XSLT probably won't help :p

> I am sorry, probably I didn't express myself correctly.
> I mean I don't want to get the full list of dependencies.
> I want to get the *actual* path of dependencies.
>
> For example, if a target might be called (as a dependency) from two other targets, I want to get only the target that actually called me, not every other target.
>
> That is why I am talking with a "live" solution, from inside the task...
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

-- 
Scot P. Floess             RHCT  (Certificate Number 605010084735240)
Chief Architect FlossWare  http://sourceforge.net/projects/flossware
                            http://flossware.sourceforge.net
                            https://github.com/organizations/FlossWare

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


Re: How to get the stack of targets, from inside a task?

Posted by Panayotis Katsaloulis <pa...@panayotis.com>.
On 24 Φεβ 2011, at 4:52 μ.μ., Scot P. Floess wrote:

> 
>> Well, since (due to dependencies) the same target can be called from different other targets,
>> I am more interested on the actual stack of targets, which I believe could not be found with XSLT...
> 
> No, you can definitely do that with XSLTt...  You can easily build up a list of dependencies...  I happened to have generated this in HTML, but you can just as easily have the XSLT generate a properties file if you wanted...
> 
> With XSLT you can select all targets with a depends attribute...  You can then iterate over values found in the depends attribute and match on all targets whose name attribute is from each value found in the depends...
> 
> My point is, it is possible...
> 
> If all you want is the list as you describe below - that should be simple in XSLT...  Can help you off list if you want...

I am sorry, probably I didn't express myself correctly.
I mean I don't want to get the full list of dependencies.
I want to get the *actual* path of dependencies.

For example, if a target might be called (as a dependency) from two other targets, I want to get only the target that actually called me, not every other target.

That is why I am talking with a "live" solution, from inside the task...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How to get the stack of targets, from inside a task?

Posted by "Scot P. Floess" <sf...@nc.rr.com>.
> Well, since (due to dependencies) the same target can be called from different other targets,
> I am more interested on the actual stack of targets, which I believe could not be found with XSLT...

No, you can definitely do that with XSLTt...  You can easily 
build up a list of dependencies...  I happened to have generated this in 
HTML, but you can just as easily have the XSLT generate a properties file 
if you wanted...

With XSLT you can select all targets with a depends attribute...  You can 
then iterate over values found in the depends attribute and match on all 
targets whose name attribute is from each value found in the depends...

My point is, it is possible...

If all you want is the list as you describe below - that should be simple 
in XSLT...  Can help you off list if you want...

>>>
>>> I am trying to develop a custom ant task, which ideally would like to get hold of the stack of all parent targets.
>>> For example in this  configuration:
>>>
>>> <target name="one" depends="two,three"/>
>>>
>>> <target name="two"/>
>>>
>>> <target name="three" depends="four"/>
>>>
>>> <target name="four">
>>> 	<customtask />
>>> </target>
>>>
>>>
>>> if the command "ant one" was executed from the command line, I'd like to get a list like this (in the task customtask):
>>> one, three, four
>>>
>>> In the documentation I found only the method getOwningTarget() which would only return the current target, "four".
>>>
>>> Is there any way to do this?

-- 
Scot P. Floess             RHCT  (Certificate Number 605010084735240)
Chief Architect FlossWare  http://sourceforge.net/projects/flossware
                            http://flossware.sourceforge.net
                            https://github.com/organizations/FlossWare

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


Re: How to get the stack of targets, from inside a task?

Posted by Panayotis Katsaloulis <pa...@panayotis.com>.
On 24 Φεβ 2011, at 3:47 μ.μ., Scot P. Floess wrote:

> 
> I've done something like this - but with XSLT...
> 
> I'm guessing you aren't interested in this to simply display the information?
> 

Well, since (due to dependencies) the same target can be called from different other targets, 
I am more interested on the actual stack of targets, which I believe could not be found with XSLT...


> On Thu, 24 Feb 2011, Panayotis Katsaloulis wrote:
> 
>> Hello people!
>> 
>> I am trying to develop a custom ant task, which ideally would like to get hold of the stack of all parent targets.
>> For example in this  configuration:
>> 
>> <target name="one" depends="two,three"/>
>> 
>> <target name="two"/>
>> 
>> <target name="three" depends="four"/>
>> 
>> <target name="four">
>> 	<customtask />
>> </target>
>> 
>> 
>> if the command "ant one" was executed from the command line, I'd like to get a list like this (in the task customtask):
>> one, three, four
>> 
>> In the documentation I found only the method getOwningTarget() which would only return the current target, "four".
>> 
>> Is there any way to do this?

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


Re: How to get the stack of targets, from inside a task?

Posted by "Scot P. Floess" <sf...@nc.rr.com>.
I've done something like this - but with XSLT...

I'm guessing you aren't interested in this to simply display the 
information?

On Thu, 24 Feb 2011, Panayotis Katsaloulis wrote:

> Hello people!
>
> I am trying to develop a custom ant task, which ideally would like to get hold of the stack of all parent targets.
> For example in this  configuration:
>
> <target name="one" depends="two,three"/>
>
> <target name="two"/>
>
> <target name="three" depends="four"/>
>
> <target name="four">
> 	<customtask />
> </target>
>
>
> if the command "ant one" was executed from the command line, I'd like to get a list like this (in the task customtask):
> one, three, four
>
> In the documentation I found only the method getOwningTarget() which would only return the current target, "four".
>
> Is there any way to do this?
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

-- 
Scot P. Floess             RHCT  (Certificate Number 605010084735240)
Chief Architect FlossWare  http://sourceforge.net/projects/flossware
                            http://flossware.sourceforge.net
                            https://github.com/organizations/FlossWare

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