检查两个antcalls是全成 [英] Check if two antcalls are successfull

查看:144
本文介绍了检查两个antcalls是全成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常新ant脚本,我想看看我的构建成功与否。我的主要目标有两个antcalls,我不知道如何检查,如果他们成功与否,以评估的主要对象。

I'm extremely new to ant script and i want to find out if my build is successful or not. my main target has two antcalls and i don't know how to check if they were successful or not, in order to evaluate the main target.

运行所有是我的主要目标

run all is my main target

<target name="run all">
<antcall target="Run basic configuration" />
<antcall target="Run custom configuration"/>

我想添加失败状态为运行所有的目标。
每个目标并逐个检查,如果他们是成功的,但我想知道,如果调用蚂蚁的目标的情况下,这两个失败不成功。
另外,如果其中一个出现故障确实另外一个被调用?

i want to add a fail condition for the "run all" target. Each target does check individually if they are successful, but I want to know if the target that calls the ant is unsuccessful in case those two fail. Also, if one fails does the other one get called?

推荐答案

要确定是否有antcall成功需要什么成功是一个更谨慎的定义。这可能意味着:

To determine if an antcall is successful requires a more careful definition of what success is. It can mean:


  1. 未抛出异常执行的code。

  2. 的code你想要的东西做的事。

在第一种情况下,你可以用你的antcall的有 trycatch 块捕捉异常的执行。的 trycatch 的任务是蚂蚁的contrib的一部分,但是这是经常使用在蚂蚁的编码。你会怎么做:

In the first case, you can wrap the execution of your antcall with a trycatch block to catch exceptions. The trycatch task is part of ant-contrib, but that is frequently used in Ant coding. You'd do:

<trycatch property="exception.message" reference="exception.object">
<try>
   <antcall target="targetName"/>
</try>
<catch>
   <!-- handle exception logic here -->
</catch>
<finally>
   <!-- do any final cleanup -->
</finally>
</trycatch>

在第二种情况下,你需要传递给调用者的一些状态指示code做你想让它做什么。

In the second case, you need to pass back to the caller some state that indicates that the code did what you wanted it to do.

注意antcall任务重新加载Ant文件(例如,build.xml文件),因此它可以是一个昂贵的操作。有替代品使用antcall任务:

Note that the antcall task reloads the ant file (e.g., build.xml), so it can be an expensive operation. There are alternatives to using the antcall task:


  • 使用的 antcallback 任务(蚂蚁的contrib)。该 antcallback 任务专门针对需要传回的数据。

  • 使用的取决于定义一个目标时,将调用相关的任务属性。

  • 使用的 runtarget 任务(蚂蚁的contrib)。随着runtarget,所有的属性都过去了,你在你的目标设置任何属性都可以给调用者。

  • 使用的 macrodef 任务。它避免了蚂蚁文件的重新解析,可以传递与默认值的属性,可以传递嵌套元素,等等。因此,这是在大多数情况下,preferred溶液

  • Use the antcallback task (ant-contrib). The antcallback task specifically addresses the need to pass back data.
  • Use the depends attribute when defining a target to call dependent tasks.
  • Use the runtarget task (ant-contrib). With runtarget, all of your properties are passed and any properties you set in your target are available to the caller.
  • Use the macrodef task. It avoids reparsing of the ant file, can be passed attributes with default values, can be passed nested elements, and more. As such, this is the preferred solution in most cases.

在每个案件上面,你可以在调用目标检查刚刚成立的回报属性来确定被叫或依赖的目标是否做你所期望他们做的事。

In each of the cases above, just set return properties that you can inspect in the calling target to determine whether the called or dependent targets did what you expected them to do.

这篇关于检查两个antcalls是全成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆