In case you cannot use Gradle, here is how to get Groovy task in Ant, and how to call a macro from Groovy.
<taskdef classname="org.codehaus.groovy.ant.Groovy" name="groovy">
<classpath>
<pathelement location="bin/groovy-ant-2.1.4.jar">
<pathelement location="bin/groovy-all-2.1.4.jar">
</pathelement></pathelement></classpath>
</taskdef>
<target name="test-groovy">
<groovy>
println "Hello World"
def ant = new AntBuilder( project )
ant.testmacro( dir: "qwerty" )
</groovy>
</target>
<macrodef name="testmacro">
<attribute name="dir">
<sequential>
<echo message="parameter: @{dir}">
</echo></sequential>
</attribute></macrodef>