我是ANT的初学者。
我做错了什么? ant-contrib-1.0b3,可用。我想按如下方式调用默认目标:
<target name="build">
<if>
<equals arg1="${config.name}" arg2="foo" />
<then>
<depends="get-all-war,..." />
</then>
<elseif>
<equals arg1="${config.name}" arg2="mark" />
<then>
<depends="zip-wars, ..." />
</then>
</elseif>
<else>
<depends="get-all-war, zip-wars, docs, deleteAll" />
</else>
</if>
答案 0 :(得分:3)
您需要使用antcall来执行其他目标。
<target name="build">
<if>
<equals arg1="${config.name}" arg2="foo" />
<then>
<antcall target="get-all-war" />
<antcall target="..." />
</then>
<elseif>
<equals arg1="${config.name}" arg2="mark" />
<then>
<antcall target="zip-wars" />
<antcall target="..." />
</then>
</elseif>
<else>
<antcall target="get-all-war" />
<antcall target="zip-wars" />
<antcall target="docs" />
<antcall target="deleteAll" />
</else>
</if>
答案 1 :(得分:0)
你可以使用宏巧妙地做同样的事情。如果你的目标是全面战争,zip-war,docs,deleteAll需要更多时间,你可以像这样并行运行它们:
<target name="build">
<if>
<equals arg1="${config.name}" arg2="foo" />
<then>
<mGetAllWar/>
</then>
<elseif>
<equals arg1="${config.name}" arg2="mark" />
<then>
<mZipWars />
</then>
</elseif>
<else>
<mRestAllTargets/>
</else>
</if>
<mGetAllWar>
<parallel>
<antcall name="target1">
<antcall name="target2">
...
</parallel>
</mGetAllWar>
<mZipWars >
<parallel>
<antcall name="target1">
<antcall name="target2">
...
</parallel>
</mZipWars >
<mRestAllTargets>
<parallel>
<antcall name="target1">
<antcall name="target2">
...
</parallel>
</mRestAllTargets>