我的ant脚本只适用于>=1.8版本。我想检查脚本中的版本,以便它显示错误,如果安装了较低的版本。
发布于 2012-05-09 18:40:07
Ant具有内置属性ant.version
<project default="print-version">
<target name="print-version">
<echo>${ant.version}</echo>
</target>
</project>
发布于 2012-05-25 05:06:26
下面是一个可能有帮助的代码片段:
<property name="version.required" value="1.8" />
<target name="version_check">
<antversion property="version.running" />
<fail message="FATAL ERROR: The running Ant version, ${version.running}, is too old.">
<condition>
<not>
<antversion atleast="${version.required}" />
</not>
</condition>
</fail>
</target>
<target name="doit" depends="version_check">
<echo level="info" message="The running version of ant, ${version.running}, is new enough" />
</target>
发布于 2014-10-28 22:39:49
无需创建目标,您可以在脚本开头使用fail+antversion:
<fail message="Ant 1.8+ required">
<condition>
<not><antversion atleast="1.8" /></not>
</condition>
</fail>
https://stackoverflow.com/questions/10514222
复制相似问题