ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: How to know if a perticular macro is defined or not
Date Wed, 16 Dec 2009 10:39:40 GMT
>Which are the ant API  we should use to know if a macro with name xyz
is
>defined or not.. 
>
>for knowing the existing of targets I can use project.getTargets() to
check
>out is there a similar thing for macros.

<project>

    <macrodef name="mymacro">
        <sequential/>
    </macrodef>
    
    <script language="javascript"> <![CDATA[
        if (project.createTask("mymacro") == null) {
            project.log("mymacro does NOT exist");
        } else {
            project.log("mymacro does exist");
        }
        
        if (project.createTask("mymacro2") == null) {
            project.log("mymacro2 does NOT exist");
        } else {
            project.log("mymacro2 does exist");
        }
    ]]></script>

</project>



mymacro does exist
mymacro2 does NOT exist

BUILD SUCCESSFUL





Jan

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


Mime
View raw message