【发布时间】:2011-01-04 05:40:27
【问题描述】:
当使用 taskdef 声明外部 ant 任务时,例如 ant-contrib,建议的设置是使用以下 taskdef:
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="lib/ant-contrib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
当 antcontrib.properties 相对于 build.xml 文件位于 net/sf/antcontrib 中时,此方法有效。
但是当我把它放在 lib/net/sf/antcontrib 中并将 taskdef 更改为
<taskdef resource="lib/net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="lib/ant-contrib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
Ant 无法找到属性文件,它给出了错误
[taskdef] Could not load definitions from resource
lib/net/sf/antcontrib/antcontrib.properties. It could not be found.
好像ant单独对待lib目录,无法从那里加载taskdef资源。
【问题讨论】: