ant构建时候的错误

ant会加载构建文件的所有元素。它将处理除目标(target)元素意外的所有元素。
如发现一个无法解析的元素 <othersssssss>元素,这将会让构建终止。发现一个错误就会立即中断。

目标级错误
ant不是将<target> 元素嵌套的各个元素全部都加载,而是逐个加载和处理各个元素。当ant到达第二个元素(嵌套在target中的第二个元素),那么会认为第一个元素(嵌套在target中的第一个元素)已经成功。

例子
<?xml version="1.0" encoding="utf-8"?>
<project name="测试" default="all" basedir=".">
<property name="build.dir" value="build" />
<property name="build.classes" value="${build.dir}/classes" />
<property naame="test" value="test value" />
<notareeeeee/>
</project>
运行后提示错误:

D:\source\liyixing\ant>d:\soft\liyixing\ant\apache-ant-1.8.2\bin\ant
Buildfile: D:\source\liyixing\ant\build.xml

BUILD FAILED
D:\source\liyixing\ant\build.xml:5: property doesn't support the "naame" attribu
te

Total time: 0 seconds

build.xml第五行,property元素不存在naame属性。

将naame属性改成name,将提示第二个错误
D:\source\liyixing\ant>d:\soft\liyixing\ant\apache-ant-1.8.2\bin\ant
Buildfile: D:\source\liyixing\ant\build.xml

BUILD FAILED
D:\source\liyixing\ant\build.xml:6: Problem: failed to create task or type notar
eeeeee
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
无法处理notareeeeee元素。

去掉这个元素后
D:\source\liyixing\ant>d:\soft\liyixing\ant\apache-ant-1.8.2\bin\ant
Buildfile: D:\source\liyixing\ant\build.xml

BUILD FAILED
Target "all" does not exist in the project "测试".

Total time: 0 seconds
依然提示错误,因为all目标未定义。

做一下修改
<?xml version="1.0" encoding="utf-8"?>
<project name="测试" default="all" basedir=".">
<property name="build.dir" value="build" />
<property name="build.classes" value="${build.dir}/classes" />
<target name="all" description="所有操作,执行顺序是:clean, compile, jar" depends="clean, compile, jar">
<notareeeeee/>
</target>
<property name="test" value="test value" />
</project>
运行结果

D:\source\liyixing\ant>d:\soft\liyixing\ant\apache-ant-1.8.2\bin\ant
Buildfile: D:\source\liyixing\ant\build.xml

BUILD FAILED
D:\source\liyixing\ant\build.xml:8: property doesn't support the "naame" attribu
te

Total time: 0 seconds

可以看出来它的错误是naame属性不支持。而不是<notareeeeee/>元素无法处理。因为构建的时候target的内部错误只能在执行target才会发现。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值