将下载的 Ivy 包,进行示例程序 hello-ivy 编译的时候出现下面的错误:[code]D:\apache-ivy-2.2.0\src\example\hello-ivy>ant
Buildfile: D:\apache-ivy-2.2.0\src\example\hello-ivy\build.xml
resolve:
BUILD FAILED
D:\apache-ivy-2.2.0\src\example\hello-ivy\build.xml:38: Problem: failed to create task or
type antlib:org.apache.ivy.ant:retrieve
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / 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:
-D:\Dkits\ant\lib
-C:\Documents and Settings\YUCHENGHU.ant\lib
-a directory added on the command line with the -lib argument
Total time: 1 second
D:\apache-ivy-2.2.0\src\example\hello-ivy>ant
Buildfile: D:\apache-ivy-2.2.0\src\example\hello-ivy\build.xml
resolve:
BUILD FAILED
D:\apache-ivy-2.2.0\src\example\hello-ivy\build.xml:38: Problem: failed to create task or
type antlib:org.apache.ivy.ant:retrieve
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / 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:
-D:\Dkits\ant\lib
-C:\Documents and Settings\YUCHENGHU.ant\lib
-a directory added on the command line with the -lib argument
Total time: 0 seconds[/code]这是因为你的 ANT 环境中没有包含有 Ivy 的库。
![]()
只需要简单的将你下载的 Ivy 包中的 ivy-2.2.0.jar 文件拷贝到你 ant 的 lib 目录下就可以了。
这里不同的版本会有不同的包的名字。
当你完成这个操作后,重新执行 ant 命令,边可以正常完成编译了。
编译输出内容如下:[code]D:\apache-ivy-2.2.0\src\example\hello-ivy>ant
Buildfile: D:\apache-ivy-2.2.0\src\example\hello-ivy\build.xml
resolve:
[ivy:retrieve] :: Ivy 2.2.0 - 20100923230623 :: Home | Apache Ivy ™ ::
[ivy:retrieve] :: loading settings :: url = jar:file:/D:/Dkits/ant/lib/ivy-2.2.0.jar!/org/
apache/ivy/core/settings/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@YUCHENG
[ivy:retrieve] confs: [default]
[ivy:retrieve] found commons-lang#commons-lang;2.0 in public
[ivy:retrieve] found commons-cli#commons-cli;1.0 in public
[ivy:retrieve] found commons-logging#commons-logging;1.0 in public
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/com
mons-lang-2.0.jar …
[ivy:retrieve] …
…
…
… (165kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar (1125ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/com
mons-lang-2.0-javadoc.jar …
[ivy:retrieve] …
…
…
…
…
…
…
…
…
…
… (467kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar(javadoc) (131
2ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/com
mons-lang-2.0-sources.jar …
[ivy:retrieve] …
…
…
…
…
… (245kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar(source) (938m
s)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commo
ns-cli-1.0-javadoc.jar …
[ivy:retrieve] …
…
… (92kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar(javadoc) (1000ms
)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commo
ns-cli-1.0.jar …
[ivy:retrieve] … (29kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar (984ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commo
ns-cli-1.0-sources.jar …
[ivy:retrieve] …
… (48kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar(source) (984ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-logging/commons-logging/1
.0/commons-logging-1.0.jar …
[ivy:retrieve] … (21kB)
[ivy:retrieve] … (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-logging#commons-logging;1.0!commons-logging.jar (100
0ms)
[ivy:retrieve] :: resolution report :: resolve 6641ms :: artifacts dl 7375ms
[ivy:retrieve] :: evicted modules:
[ivy:retrieve] commons-lang#commons-lang;1.0 by [commons-lang#commons-lang;2.0] in [defau
lt]
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 4 | 3 | 3 | 1 || 7 | 7 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.apache#hello-ivy
[ivy:retrieve] confs: [default]
[ivy:retrieve] 0 artifacts copied, 7 already retrieved (0kB/110ms)
run:
[javac] D:\apache-ivy-2.2.0\src\example\hello-ivy\build.xml:53: warning: ‘includeantru
ntime’ was not set, defaulting to build.sysclasspath=last; set to false for repeatable bui
lds
[java] standard message : hello ivy !
[java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !
BUILD SUCCESSFUL
Total time: 17 seconds
D:\apache-ivy-2.2.0\src\example\hello-ivy>[/code]
