ivy和maven使用概述

来源:互联网 发布:javascript源码分析 编辑:程序博客网 时间:2024/05/17 01:38

一:需求

将一个老的标准 web 工程,在不改变目录结构的前提下添加依赖管理。并且做到对开发人员透明,不增加开发人员在开发过程中的配置和学习成本。

二:现状

通过了解,兄弟产品对标准 web 工程添加“依赖管理”后,通过手动、批处理、 ant 等方式执行拷贝 jar 包命令,将 jar 包拷贝到工程的 lib 目录中。

mvn copy-dependencies -DoutputDirectory=${lib.dir}"

 

三:概念

1 、什么是 apache ivy ?

Ivy is a tool for managing (recording, tracking, resolving and reporting) project dependencies. It is characterized by the following:

flexibility and configurability - Ivy is essentially process agnostic and is not tied to any methodology or structure. Instead it provides the necessary flexibility and configurability to be adapted to a broad range of dependency management and build processes.

tight integration with Apache Ant - while available as a standalone tool, Ivy works particularly well with Apache Ant providing a number of powerful Ant tasks ranging from dependency resolution to dependency reporting and publication.

Ivy is open source and released under a very permissive Apache License.

 

Ivy has a lot of powerful Features, the most popular and useful being its flexibility, integration with ant, and its strong transitive dependencies management engine.

 

The transitive dependencies management is a feature which lets you get dependencies of your dependencies, transitively. In order to address this general problem, ivy needs to find metadata about your modules, usually in an ivy file. To find the metadata and your dependencies' artifacts (usually jars), Ivy can be configured to use a lot of different repositories.

 

2 、 apache ivy 和 apache maven 对比?

First, the most important difference is that they aren't at all the same kind of tools. Apache Maven is a software project management and comprehension tool, whereas Apache Ivy is only a dependency management tool, highly integrated with Apache Ant™, the popular build management tool. So maybe a more interesting comparison would compare Apache Ant+Ivy vs Apache Maven. But this goes beyond the scope of this page which concentrates on dependency management only.

 

以上内容来自 apache ivy 官方网站 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 无缝转换。

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yirentianran/archive/2011/05/26/6448433.aspx