|
Ant example source code file (macrodef.xml)
The macrodef.xml source code<project> <target name="simple"> <macrodef name="my.echo"> <attribute name="text"/> <sequential> <echo message="@{text}"/> </sequential> </macrodef> <my.echo text="Hello World"/> </target> <target name="text"> <macrodef name="my.echo"> <attribute name="text"/> <sequential> <echo>@{text} </sequential> </macrodef> <my.echo text="Inner Text"/> </target> <target name="duplicate.attribute"> <macrodef name="my.echo"> <attribute name="text"/> <attribute name="text"/> <sequential> <echo>@{text} </sequential> </macrodef> </target> <target name="duplicate.element"> <macrodef name="my.echo"> <element name="text"/> <element name="text"/> <sequential> <text/> </sequential> </macrodef> </target> <target name="uri"> <macrodef name="echo" uri="abc"> <attribute name="text"/> <sequential> <echo message="@{text}"/> </sequential> </macrodef> <x:echo xmlns:x="abc" text="Hello World"/> </target> <target name="nested"> <macrodef name="nested"> <element name="nested"/> <sequential> <nested/> </sequential> </macrodef> <nested> <nested> <echo>A nested element </nested> </nested> </target> <target name="double"> <macrodef name="double"> <attribute name="prop"/> <sequential> <echo>@@{prop} is '@{prop}', value of $${@{prop}} is '${@{prop}}' </sequential> </macrodef> <property name="property" value="A property value"/> <double prop="property"/> </target> <target name="ignorecase"> <macrodef name="ignore"> <attribute name="MyAttribute"/> <sequential> <echo>@{myattribute} is @{MYATTRIBUTE} </sequential> </macrodef> <ignore myattribute="a"/> <ignore Myattribute="b"/> </target> <target name="ignore-element-case"> <macrodef name="ignore"> <element name="MyElement"/> <sequential> <myElement/> <MyElEmEnT/> </sequential> </macrodef> <ignore> <MYELEMENT> <echo>nested element </MYELEMENT> </ignore> </target> <target name="textelement"> <macrodef name="echotest"> <text name="text" optional="yes"/> <sequential> <echo>@{text} </sequential> </macrodef> <echotest> Hello world </echotest> </target> <target name="text.trim"> <macrodef name="echotest"> <text name="text" trim="yes"/> <sequential> <echo>[@{text}] </sequential> </macrodef> <echotest> Hello world </echotest> </target> <target name="duplicatetextname"> <macrodef name="echotest"> <attribute name="text"/> <text name="text"/> <sequential> <echo>@{text} </sequential> </macrodef> </target> <target name="duplicatetextname2"> <macrodef name="echotest"> <text name="text"/> <attribute name="text"/> <sequential> <echo>@{text} </sequential> </macrodef> </target> <target name="escape"> <macrodef name="escape"> <attribute name="a"/> <attribute name="b"/> <sequential> <echo>a@b or a@@b is @{a}@@@{b} </sequential> </macrodef> <escape a="avalue" b="bvalue"/> </target> <target name="attribute.description"> <macrodef name="d"> <attribute name="description"/> <attribute name="d" default="p"/> <sequential> <echo>description is @{description} </sequential> </macrodef> <d description="hello world"/> </target> <target name="implicit"> <macrodef name="implicit"> <element name="implicit" implicit="yes"/> <sequential> <echo>Before implicit <implicit/> <echo>After implicit </sequential> </macrodef> <implicit> <echo>In implicit </implicit> </target> <target name="implicit.notoptional"> <macrodef name="implicit"> <element name="implicit" implicit="yes"/> <sequential> <echo>Before implicit <implicit/> <echo>After implicit </sequential> </macrodef> <implicit> </implicit> </target> <target name="implicit.optional"> <macrodef name="implicit"> <element name="implicit" optional="yes" implicit="yes"/> <sequential> <echo>Before implicit <implicit/> <echo>After implicit </sequential> </macrodef> <implicit> </implicit> </target> <target name="implicit.explicit"> <macrodef name="implicit"> <element name="explicit" optional="yes"/> <element name="implicit" optional="yes" implicit="yes"/> <sequential> <implicit/> <explicit/> </sequential> </macrodef> </target> <property name="default.override" value="old"/> <macrodef name="simple.override"> <attribute name="attr" default="${default.override}"/> <sequential> <echo>value is @{attr} </sequential> </macrodef> <target name="override.default"> <antcall target="override.call"> <param name="default.override" value="new"/> </antcall> </target> <target name="override.call"> <simple.override/> </target> <target name="backtraceoff"> <macrodef name="nobacktrace" backtrace="false"> <sequential> <fail>This is a failure </sequential> </macrodef> <nobacktrace/> </target> <target name="backtraceon"> <macrodef name="nobacktrace" backtrace="true"> <sequential> <fail>This is a failure </sequential> </macrodef> <nobacktrace/> </target> <target name="top-level-text"> <macrodef name="top"> <element name="em"/> <sequential> <echo> </sequential> </macrodef> <top> <em> Hello World </em> </top> </target> </project> Other Ant examples (source code examples)Here is a short list of links related to this Ant macrodef.xml source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.