Reputation: 229
I've created a macro to compile .swf
from .as
sources (Flash projects) :
<macrodef name="compile">
<sequential>
<mxmlc file="@{input}" output="@{output}"/>
</sequential>
</macrodef>
Once created, I call it in my build.xml
:
<target name="compile.app1">
<compile input="App1.as" output="app1.swf"/>
</target>
To avoid compiling my App1
each time, I've added the task <uptodate>
in <compile>
:
<macrodef name="compile">
<sequential>
<uptodate property="swf.uptodate" targetfile="@{output}">
<srcfiles dir="@{src}" includes="**/*.as"/>
</uptodate>
<mxmlc file="@{input}" output="@{output}"/>
</sequential>
</macrodef>
But at this point, I don't know how I can bind the swf.uptodate
property with the mxmlc
task. Here is what I would like to do :
IF NOT swf.uptodate
EXECUTE mxmlc
ELSE
do nothing.
Upvotes: 1
Views: 1369
Reputation: 10377
No need for antcontrib, with ant >= 1.9.1 use the new if/unless feature introduced with Ant 1.9.1 (better use Ant 1.9.3 because of bugs in Ant 1.9.1 see this answer for details)
To activate that feature you need the namespace declarations, as seen in the following snippet :
<project
xmlns:if="ant:if"
xmlns:unless="ant:unless"
>
<macrodef name="compile">
<sequential>
<uptodate property="swf.uptodate" targetfile="@{output}">
<srcfiles dir="@{src}" includes="**/*.as"/>
</uptodate>
<mxmlc file="@{input}" output="@{output}" unless:true="${swf.uptodate}"/>/>
</sequential>
</macrodef>
</project>
Otherwise when using ant <= 1.9.1 you may use script task with builtin javascript engine, if you want to avoid using ant addons like antcontrib.
Upvotes: 2