首先,Ant比Maven更早,因此不包括依赖管理的核心支持 .
添加常 Spring 藤
Ivy是Ant的依赖管理框架
要启用它,您需要做两件事 . 首先将常 Spring 藤任务命名空间包含在构建文件的顶部:
其次,您需要将常 Spring 藤 jar 安装到ANT用于其第三方扩展的标准位置之一:
$ ANT_HOME / lib
$ HOME / .ant / lib
我喜欢让我的构建独立,所以包括一个自动执行此操作的目标:
使用常 Spring 藤
这是一个非常广泛的主题,以下是一个简单的例子来下载hibernate jar及其依赖项:
产生以下输出:
resolve:
[ivy:cachepath] :: Apache Ivy 2.3.0 - 20130110142753 :: http://ant.apache.org/ivy/ ::
[ivy:cachepath] :: loading settings :: url = jar:file:/home/mark/.ant/lib/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:cachepath] :: resolving dependencies :: #;working@mark
[ivy:cachepath] confs: [default]
[ivy:cachepath] found org.hibernate#hibernate;3.2.7.ga in public
[ivy:cachepath] found net.sf.ehcache#ehcache;1.2.3 in public
[ivy:cachepath] found commons-logging#commons-logging;1.0.4 in public
[ivy:cachepath] found asm#asm-attrs;1.5.3 in public
[ivy:cachepath] found dom4j#dom4j;1.6.1 in public
[ivy:cachepath] found antlr#antlr;2.7.6 in public
[ivy:cachepath] found cglib#cglib;2.1_3 in public
[ivy:cachepath] found asm#asm;1.5.3 in public
[ivy:cachepath] found commons-collections#commons-collections;2.1.1 in public
[ivy:cachepath] :: resolution report :: resolve 373ms :: artifacts dl 10ms
[ivy:cachepath] :: evicted modules:
[ivy:cachepath] commons-collections#commons-collections;2.1 by [commons-collections#commons-collections;2.1.1] in [default]
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 10 | 0 | 0 | 1 || 9 | 0 |
---------------------------------------------------------------------
然后可以在您的javac任务中使用此常 Spring 藤托管类路径