You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Raja Nagendra Kumar <Na...@tejasoft.com> on 2009/09/02 18:18:32 UTC

how to call a predefined target or macroin build.xml from Custom Ant task

Hi,

I am looking to call a Macro defined in the project though custom task.
Similarly calling of target.
Both macro and target are defined the build.xml and my java based custom
task should be able to call it with min overhead.. i.e with the same
overhead as calling the macro from build.xml or calling one target from
other either by depends.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com




-- 
View this message in context: http://www.nabble.com/how-to-call-a-predefined-target-or-macroin-build.xml-from-Custom-Ant-task-tp25260761p25260761.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


AW: AW: how to call a predefined target or macroin build.xml from Custom Ant task

Posted by Ja...@rzf.fin-nrw.de.
macro = ...createTask(...);
for(...) {
   macro.setDynamic(...)
   macro.execute();
} 

This should work. My example reused that too (1st with default value, 2nd run with custom value).
You have to ensure that no required values are "deleted" in further runs. But if all runs require
the setting of the same parameters (maybe with different values) this should be enough.


Jan

>-----Ursprüngliche Nachricht-----
>Von: Raja Nagendra Kumar [mailto:Nagendra.Raja@tejasoft.com] 
>Gesendet: Donnerstag, 3. September 2009 10:10
>An: dev@ant.apache.org
>Betreff: Re: AW: how to call a predefined target or macroin 
>build.xml from Custom Ant task
>
>
>Thank You Jon, this rocks..
>
>instead of createTask() every time, is there a way to reuse the already
>existing one (either may be created by xml files or with in 
>other script
>file..)
>
>Not sure how memory and cpu intesive is createTask() specially 
>when it is
>for loop (in our case this macro is run many times).
>
>Regards,
>Raja Nagendra Kumar
>TejaSoft
>
>
>-- 
>View this message in context: 
>http://www.nabble.com/how-to-call-a-predefined-target-or-macroi
>n-build.xml-from-Custom-Ant-task-tp25260761p25271525.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
>
>

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


Re: AW: how to call a predefined target or macroin build.xml from Custom Ant task

Posted by Raja Nagendra Kumar <Na...@tejasoft.com>.
Thank You Jon, this rocks..

instead of createTask() every time, is there a way to reuse the already
existing one (either may be created by xml files or with in other script
file..)

Not sure how memory and cpu intesive is createTask() specially when it is
for loop (in our case this macro is run many times).

Regards,
Raja Nagendra Kumar
TejaSoft


-- 
View this message in context: http://www.nabble.com/how-to-call-a-predefined-target-or-macroin-build.xml-from-Custom-Ant-task-tp25260761p25271525.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


AW: how to call a predefined target or macroin build.xml from Custom Ant task

Posted by Ja...@rzf.fin-nrw.de.
<project>

<macrodef name="echo1">
    <attribute name="foo" default="default"/>
    <sequential>
        <echo message="@{foo}"/>
    </sequential>
</macrodef>
<script language="javascript">
<![CDATA[
    // Create the macro like a normal task
    task = project.createTask("echo1");
    // and execute it
    task.execute();
    
    // setting attributes like normal tasks doesnt work because there is no setter
    // implemented.
    //    task.setFoo("my text");
    // so the macro uses a dynamic way defined in org.apache.tools.ant.DynamicAttribute here
    task.setDynamicAttribute("foo", "my text");
    task.execute();
]]>
</script>

</project>



Jan 

>-----Ursprüngliche Nachricht-----
>Von: Raja Nagendra Kumar [mailto:Nagendra.Raja@tejasoft.com] 
>Gesendet: Mittwoch, 2. September 2009 20:25
>An: dev@ant.apache.org
>Betreff: Re: how to call a predefined target or macroin 
>build.xml from Custom Ant task
>
>
>Hi,
>
>I see there is a way to execut target using 
>getProject().executeTarget()..
>but don't find a way to execute the macro. Any pointers pl.
>
>Regards,
>Nagendra
>
>
>
>-- 
>View this message in context: 
>http://www.nabble.com/how-to-call-a-predefined-target-or-macroi
>n-build.xml-from-Custom-Ant-task-tp25260761p25263010.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
>
>

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


Re: how to call a predefined target or macroin build.xml from Custom Ant task

Posted by Raja Nagendra Kumar <Na...@tejasoft.com>.
Hi,

I see there is a way to execut target using getProject().executeTarget()..
but don't find a way to execute the macro. Any pointers pl.

Regards,
Nagendra



-- 
View this message in context: http://www.nabble.com/how-to-call-a-predefined-target-or-macroin-build.xml-from-Custom-Ant-task-tp25260761p25263010.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