我的 ant 脚本只适用于 >=1.8 的版本。我想检查脚本中的版本,以便在安装较低版本时显示错误。
最佳答案
这是一个可能有帮助的代码片段:
<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>
关于java - 如何在 Ant 脚本中检查 Ant 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10514222/