Apache Ant Tasks 简明教程
Apache Ant Tasks - Fail
Description
错误任务用于通过引发 BuildException
来退出当前构建,可以选择性地打印其他信息。可以通过 message 属性或嵌套到元素中的字符数据设置异常消息。
Fail task is used to exit the current build by throwing a BuildException, optionally printing additional information. The message of the Exception can be set via the message attribute or character data nested into the element.
Properties
Sr.No |
Attributes & Description |
1 |
Message A message giving further information on why the build exited. |
2 |
If Only fail if a property of the given name exists in the current project |
3 |
Unless Only fail if a property of the given name doesn’t exist in the current project |
4 |
Status Exit using the specified status code; assuming the generated Exception is not caught, the JVM will exit with this status. |
Example
Usage
使用以下内容创建 build.xml −
Create build.xml with the following content −
<?xml version="1.0"?>
<project name="TutorialPoint" default="info">
<property name="build.dir" value="build" />
<target name="info">
<fail unless="src.dir"/>
</target>
</project>
上面的脚本将使构建失败,因为未设置 src.dir。
Above script will fail the build as src.dir is not set.