论坛首页 Java版 企业应用

如何安装apache ivy

浏览 686 次
精华帖 (0) :: 良好帖 (2) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
最后更新时间:2008-03-04 关键字: build management using ivy
IVY,它是一个管理(记录、跟踪、解析和报告)项目依赖的工具,可与ApacheAnt紧密集成,很多的信息,请参照:
http://ant.apache.org/ivy

1.代码可以从这里得到 svn co https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
2.确保你的机子上已经安装了ant (version 1.6.5 or 以上)与jdk1.5,进入$IVY_HOME(checkout svn url的目录)后,运行ant jar ,在$IVY_HOME/build会生成一些jar包,把$IVY_HOME/build/artifact/ivy.jar 和$IVY_HOME/lib/jsch.jar 拷贝到$ANT_HOME/lib(如果是windows %ANT_HOME%/lib)
3.这样就可以在build.xml用 ivy dependency

e.g:
这是个是build.xml
<project name="hello-ivy" default="run" xmlns:ivy="antlib:org.apache.ivy.ant">
    <!--引入ivy dependency -->
    <!-- some variables used -->
    <property name="lib.dir" value="lib" />
    <property name="build.dir" value="build" />
    <property name="src.dir" value="src" />
   
    <!-- paths used for compilation and run  -->
    <path id="lib.path.id">
        <fileset dir="${lib.dir}" />
</path>
    <path id="run.path.id">
        <path refid="lib.path.id" />
        <path location="${build.dir}" />
    </path>
   
    <!-- =================================
          target: resolve   得到所依赖的文件,依赖的文件在ivy.xml下设置         
         ================================= -->
    <target name="resolve" description="--> retreive dependencies with ivy">
        <ivy:retrieve/>
    </target>
   
    <!-- =================================
          target: report    导入一些report 信息         
         ================================= -->
    <target name="report" depends="resolve" description="--> generates a report of dependencies">
        <ivy:report todir="${build.dir}"/>
    </target>
   
    <!-- =================================
          target: run
         ================================= -->
    <target name="run" depends="resolve" description="--> compile and run the project">
        <mkdir dir="${build.dir}" />
        <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="lib.path.id" />
    <property name="msg" value="hello ivy !"/>
        <java classpathref="run.path.id" classname="example.Hello">
        <arg value="-message"/>
        <arg value="${msg}"/>
    </java>
    </target>

    <!-- =================================
          target: clean             
         ================================= -->
    <target name="clean" description="--> clean the project">
        <delete includeemptydirs="true">
            <fileset dir="${basedir}">
            <exclude name="src/**" />
            <exclude name="build.xml" />
              <exclude name="ivy.xml" />
        </fileset>
    </delete>
    </target>

    <!-- =================================
          target: clean-cache   删除所有依赖的缓存文件          
         ================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<ivy:cleancache />
</target>
</project>

这个是ivy.xml

<ivy-module version="1.0">
    <info organisation="apache" module="ivyrep-example"/>
    <dependencies>
        <dependency org="apache" name="commons-lang" rev="2.0"/>
        <dependency org="apache" name="commons-cli" rev="1.0"/>
    </dependencies>
</ivy-module>
   
最后更新时间:2008-03-05
特别好?对项目依赖的jar可以进行统一的管理,可以集中管理所有项目所依赖的jar包.
   
0 请登录后投票
最后更新时间:2008-03-05
请问和Maven2有什么不一样的?
   
0 请登录后投票
最后更新时间:2008-03-05
welllove53 写道
请问和Maven2有什么不一样的?

区别:Mave2,它是一个模块化项目构建工具(Building a Project )。它能够管理依赖、构建周期、测试、 打包并且在仓库中发布你的制品。它是一个项目构建工具,领先于通常的构建工具(实际上它的第一个版本是在Ant之上的一层)。apache ivy2 对项目依赖的文件可以进行统一的管理,依赖于ant,它是一个管理(记录、跟踪、解析和报告)项目依赖的工具 (dependency tool).
   
0 请登录后投票
论坛首页 Java版 企业应用

跳转论坛:
JavaEye推荐