<转自http://www.iteye.com/topic/510032>
有了Ivy的帮忙,我们不需要为了一个库依赖管理而舍弃Ant去学那个难搞的Maven了。
基本配置步骤如下:
1、copy Ivy插件(见附件)到ant_home/lib下;
2、在项目根目录下新建ivysettings.xml;
3、在项目根目录下新建ivy.xml,内容根据项目需要来;
4、修改你原来的build.xml,如下:
- 增加ivy需要的属性:
-
<property name="publish.version" value="0.1" />
-
<property name="ivy.report.todir" value="build" />
-
<property name="repository.dir" value="d:/Local_Repository" />
-
- 初始化ivy:
-
<ivy:settings file="ivysettings.xml" />
-
- 添加resolve target,用于下载依赖包:
-
<target name="resolve" description="--> resolve and retrieve dependencies with ivy">
-
<ivy:resolve file="ivy.xml" conf="*" />
-
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]" />
- </target>
-
- 让原来的compile依赖于resolve:
-
<target name="compile" depends="resolve"
-
- 添加publish target,这个不是必须的:
-
<target name="publish" depends="jar" description="publish">
-
<ivy:publish resolver="local" pubrevision="${publish.version}" overwrite="true">
-
<artifacts pattern="dist/[artifact].[ext]" />
- </ivy:publish>
-
<echo message="project ${ant.project.name} released with version ${publish.version}" />
- </target>
-
- 添加report target用于生产漂亮的依赖报告,当然这个也不是必须的:
-
<target name="report" depends="resolve" description="--> resolve and retrieve dependencies with ivy">
- <ivy:report />
- </target>
增加ivy需要的属性:
<property name="publish.version" value="0.1" />
<property name="ivy.report.todir" value="build" />
<property name="repository.dir" value="d:/Local_Repository" />
初始化ivy:
<ivy:settings file="ivysettings.xml" />
添加resolve target,用于下载依赖包:
<target name="resolve" description="--> resolve and retrieve dependencies with ivy">
<ivy:resolve file="ivy.xml" conf="*" />
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]" />
</target>
让原来的compile依赖于resolve:
<target name="compile" depends="resolve"
添加publish target,这个不是必须的:
<target name="publish" depends="jar" description="publish">
<ivy:publish resolver="local" pubrevision="${publish.version}" overwrite="true">
<artifacts pattern="dist/[artifact].[ext]" />
</ivy:publish>
<echo message="project ${ant.project.name} released with version ${publish.version}" />
</target>
添加report target用于生产漂亮的依赖报告,当然这个也不是必须的:
<target name="report" depends="resolve" description="--> resolve and retrieve dependencies with ivy">
<ivy:report />
</target>
完整的build.xml示例见http://code.google.com/p/smartpagination/source/browse/trunk/build.xml
Over!
至此,你已经为蚂蚁插上了Ivy的翅膀,下面的工作只是锦上添花而已——在Eclipse配置Ivy,这个工作的作用是把ivy.xml变成classpath的一部分,使得我们只需要维护ivy.xml不需要维护.classpath文件。
配置步骤:
1、Window->preference->ant->RunTime->Classpath->Ant Home Entries,
右边Add External Jars,添加org.apache.ivy_2.1.0.cr1_20090319213629.jar。
2、安装Ivy插件:Help->Install new software->add,
Name: IvyDE,Location: http://www.apache.org/dist/ant/ivyde/updatesite
安装成功后重启eclipse;
3、重启eclipse后,Window->preference->ivy->settings
Ivy settings path设为d:/workspace/ivysettings.xml(这个值取决于你的环境)
至此,Eclipse的ivy插件配置好了,然后就可以为你的项目classpath添加ivy依赖了:
选中项目->右键 属性->Java Build Path->Libraries->Add Library...->IvyIDE Managed Dependencies->finish->OK
然后神奇的事情就出现了——虽然你一个jar包也没下载,只是在ivy.xml里面声明了一下,但是你的项目已经可以编译通过了,就好像那些第三方类库已经在你本地了一样。
更多参考http://ivy.group.iteye.com/group/wiki?page=2
分享到:
相关推荐
ant ant下载 ant配置ant ant下载 ant配置ant ant下载 ant配置
ant配置ant配ant配置ant配置置
ant的配置文件ant的配置文件ant的配置文件ant的配置文件
#蚂蚁和常春藤使用 Ant 和 Ivy 的简单项目。设置只需要安装 Ant 并从命令行访问: $ ant -versionApache Ant(TM) version 1.9.4 compiled on April 29 2014默认目标(jar) $ ant-ivy.jar.check:#...-install-ivy:#....
ANT 的安装和配置 安装在windows下
Ant的安装与配置,希望和大家交流,写的不好
这是一个ANT自编译的程序,可以在myeclipse下创建ant文件,根据代码配置,下载后直接可以用。
项目中Ant配置的实例,一次配置 稍微改动 到处使用
网络上搜集的Findbugs在Ant下的配置方法 坚决免费开放
Jenkins+SVN+Ant持续集成环境配置笔记 笔记内容为个人搭建环境流程
ANT的安装配置笔记 ANT的安装配置笔记 ANT的安装配置笔记
ant配置、实现自己的多渠道打包,对于需要者相当有参考意义。
NULL 博文链接:https://shihuan830619.iteye.com/blog/2162206
与Apache Ant紧密集成虽然可以作为独立工具使用,但Apache Ivy与Apache Ant的配合特别好,它提供了许多强大的Ant任务,从依赖关系解析到依赖关系报告和发布。最新变化: 在文件查看自上次发行以来的更改列表。支持...
Ant_build.xml配置实例,Ant的详细配置,很实用
ant依赖包,实现对代码的打包管理,在weblogic下很有用哦
Ant的配置及使用实例 Ant的配置及使用实例
里面详细说明什么是Ant,以及Ant在实战中详细配置内容,精简、实用!
Ant 配置文件详解 Ant 各种详细配置应有尽有!!!
配置junit用ant配置运行,里面介绍了如果配置,如果运行