`

Ant脚本中使用try-catch

    博客分类:
  • Ant
阅读更多
<?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>
分享到:
评论
1 楼 virtuallife 2011-12-14  
正需要这个功能,试试~

相关推荐

Global site tag (gtag.js) - Google Analytics