1

Ant 不再能够找到 ant 贡献,我很困惑,因为我不记得在机器上进行任何更改。

$ ant -f ./build-ivy.xml 
Buildfile: ./build-ivy.xml
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

BUILD FAILED
/var/lib/jenkins/jobs/Lakshmi-MySQL/workspace/build-ivy.xml:41: Problem: failed to create task or type antlib:org.apache.ivy.ant:settings
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.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -/usr/share/ant/lib
        -/var/lib/jenkins/.ant/lib
        -a directory added on the command line with the -lib argument

现在 ant-contrib jar 文件(和以前一样)在/var/lib/jenkins/.ant/lib其中并且可供用户读取

$ ls -l /var/lib/jenkins/.ant/lib/ant-contrib-1.0b3.jar
-rw-r--r-- 1 jenkins root 224277 Jun 29 09:24 /var/lib/jenkins/.ant/lib/ant-contrib-1.0b3.jar
$ jar tf /var/lib/jenkins/.ant/lib/ant-contrib-1.0b3.jar | head -n 3
META-INF/
META-INF/MANIFEST.MF
net/

编辑

使用 strace 检查:ant正在读取文件:

...
[pid 10400] stat("/var/lib/jenkins/.ant/lib/ant-contrib-1.0b3.jar", {st_mode=S_IFREG|0644, st_size=224277, ...}) = 0
[pid 10400] stat("/var/lib/jenkins/.ant/lib/ant-contrib-1.0b3.jar", {st_mode=S_IFREG|0644, st_size=224277, ...}) = 0
[pid 10400] open("/var/lib/jenkins/.ant/lib/ant-contrib-1.0b3.jar", O_RDONLY) = 15
[pid 10400] fstat(15, {st_mode=S_IFREG|0644, st_size=224277, ...}) = 0
[pid 10400] fcntl(15, F_GETFD)          = 0
[pid 10400] fcntl(15, F_SETFD, FD_CLOEXEC) = 0
[pid 10400] lseek(15, 0, SEEK_END)      = 224277
[pid 10400] lseek(15, 224149, SEEK_SET) = 224149
[pid 10400] read(15, "ls/Walls.classPK\1\2\24\3\n\0\0\0\10\0\323]b5\362j"..., 128) = 128
[pid 10400] mmap(NULL, 19477, PROT_READ, MAP_SHARED, 15, 0x32000) = 0x7fb234002000
[pid 10400] lseek(15, 43, SEEK_SET)     = 43
[pid 10400] read(15, "PK\3\4\n\0\0\0\10\0\322]b5\214\246\227\251\206\0\0\0\240\0\0\0\24\0\0\0", 30) = 30
[pid 10400] lseek(15, 93, SEEK_SET)     = 93
[pid 10400] read(15, "M\215\261\16\203 \24Ew\22\376\341\215\355\0>\264\222\224M;upj\323\265A\304\224\244\240\1"..., 134) = 134
...
4

1 回答 1

2

ANT_HOME未设置这会导致antant 1.8.4 安装中的脚本执行默认的 ant 1.7.1 二进制文件(不适用于 ant-contrib)

设置ANT_HOME为 ant 1.8.4 安装后,一切都按预期工作。

于 2012-09-06T09:41:33.593 回答