现在的位置: 首页 > 综合 > 正文

Apache Ant Ivy 笔记 (二)

2013年09月03日 ⁄ 综合 ⁄ 共 1068字 ⁄ 字号 评论关闭
 

Apache Ant Ivy 笔记 (二)

Ref: http://ant.apache.org/ivy/history/latest-milestone/tutorial/start.html

Section: The build.xml file

Tutorials: http://ant.apache.org/ivy/history/latest-milestone/tutorial.html

Ant tasks: http://ant.apache.org/ivy/history/latest-milestone/ant.html

Ant build.xml

要查看ant build文件中的所有target, 只要在命令行下输入"ant -P" 就可以了.

下面是hello-ivy的build.xml片段:

 

<project xmlns:ivy="antlib:org.apache.ivy.ant" name="hello-ivy" default="run">

...

    <!-- ================================= 
    target: resolve 
    ================================= 
-->
    
<target name="resolve" description="--> retrieve dependencies with ivy">
        
<ivy:retrieve />
    
</target>
</project>

 

可以看到, revole和retrieve dependency很简单, 只要你正确安装Ivy, 然后在build.xml中定义一个namespace, 所有Ivy ant task就全部可用了. 

xmlns:ivy="antlib:org.apache.ivy.ant"

如果没有任何设置, Ivy会从maven2 的repository获取文件. resove task 在maven 2 repository中找到了 commons-lang 和 commons-cli, 并且获知 commons-cli依赖于 commons-logging, 所以也会主动把common-logging下载下来. Ivy默认会先把相应的文件放到它的cache中 (默认是user home/.ivy2/cache目录).

最后, resolve task会将相关的jar文件都copy到项目的library目录 (默认是lib目录, 不过你可以很方便的修改, 只要设置retrieve task的属性).

 

抱歉!评论已关闭.