I want to call macrodef task (“test_task” below) defined in build.gradle from build.xml
Here’s the build.xml:
<?xml version="1.0" encoding="utf-8"?>
<project>
<target name="hello">
<property name="msg" value="Set by ant"/>
<echo>${msg}</echo>
<test_task/>
<echo>${msg}</echo>
</target>
</project>
Here’s the build.gradle:
ant.importBuild 'build.xml'
ant.macrodef (name: 'test_task') {
sequential { ant.properties['msg']='Set by gradle'}
}
I would expect the output from “gradle hello” to be: :hello [ant:echo] Set by ant [ant:echo] Set by gradle
Instead I get: :hello [ant:echo] Set by gradle [ant:echo] Set by gradle
This indicates to me that the macrodef defined in build.gradle is being executed before the “test_task” task is being fired. In fact, I can comment out the “test_task” call and still get the same output.
Any ideas how to get “macrodef” to work as is does with ANT (just define it but don’t run it)? This is part of developing a strategy for converting my ANT scripts to gradle.
Thanks