<?xml version="1.0" encoding="GBK"?>
<project name="auto_test" basedir="." default="autotest.main">
<property name="ant-contrib.jar"
<!--在ant脚本目录下,新建一个lib目录,把ant-contrib-1.0b3.jar放在里面->
location="./lib/ant-contrib-1.0b3.jar" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpath="${ant-contrib.jar}" />
<target name="autotest.init">
<echo message="autotest.init"/>
</target>
<target name="autotest.main">
<trycatch property="GetBuildError">
<try>
<antcall target="autotest.init"></antcall>
<!--sleep属性故意写错,使它报错-->
<sleep second="10" />
</try>
<catch>
<echo level="error">BUILD FAILED</echo>
</catch>
<finally>
</finally>
</trycatch>
</target>
</project>
Ant脚本中使用try-catch
最新推荐文章于 2023-03-31 10:43:12 发布