一:需求
将一个老的标准web工程,在不改变目录结构的前提下添加依赖管理。并且做到对开发人员透明,不增加开发人员在开发过程中的配置和学习成本。
二:现状
通过了解,兄弟产品对标准web工程添加“依赖管理”后,通过手动、批处理、ant等方式执行拷贝jar包命令,将jar包拷贝到工程的lib目录中。
mvn copy-dependencies-DoutputDirectory=${lib.dir}"
三:概念
1、什么是apache ivy?
Ivy is a toolfor managing (recording, tracking, resolving and reporting) projectdependencies. It is characterized by the following:
flexibility andconfigurability - Ivy is essentially process agnostic and is not tied to anymethodology or structure. Instead it provides the necessary flexibility andconfigurability to be adapted to a broad range of dependency management andbuild processes.
tightintegration with Apache Ant - while available as a standalone tool, Ivy worksparticularly well with Apache Ant providing a number of powerful Ant tasksranging from dependency resolution to dependency reporting and publication.
Ivy is opensource and released under a very permissive Apache License.
Ivy has a lot ofpowerful Features, the most popular and useful being its flexibility,integration with ant, and its strong transitive dependencies management engine.
The transitivedependencies management is a feature which lets you get dependencies of yourdependencies, transitively. In order to address this general problem, ivy needsto find metadata about your modules, usually in an ivy file. To find themetadata and your dependencies' artifacts (usually jars), Ivy can be configuredto use a lot of different repositories.
2、apache ivy和apache maven对比?
First, the mostimportant difference is that they aren't at all the same kind of tools. ApacheMaven is a software project management and comprehension tool, whereas ApacheIvy is only a dependency management tool, highly integrated with Apache Ant™,the popular build management tool. So maybe a more interesting comparison wouldcompare Apache Ant+Ivy vs Apache Maven. But this goes beyond the scope of thispage which concentrates on dependency management only.
以上内容来自apacheivy官方网站http://ant.apache.org/ivy/
四、实践
1、apache ivy在eclipse中使用
ivyde插件:
http://www.apache.org/dist/ant/ivyde/updatesite
通过ivyde添加“依赖管理”后的目录结构:
Ivyde插件在修改依赖关系时自动更新工程lib目录中jar包
2、maven2在eclipse中使用
m2eclipse插件:
http://m2eclipse.sonatype.org/sites/m2e
通过m2eclipse添加“依赖管理”后的目录结构:
目前的配置中,只能通过deploy的方式启动工程。m2eclipse插件无法将jar包拷贝原工程的lib目录下,只能拷贝到deploy后的工程的lib目录下。
原工程目录:
Deploy后的工程目录:
五:总结:
apache ivy是一个敏捷的依赖依赖管理工具,可以和ant集成起来使用。apache ivy默认使用maven2的repository ,并且可以直接使用maven2的pom.xml配置文件。所以在使用同一个pom.xml文件时,可以做到apache ivy和maven2无缝转换。