yadianna 发表于 2017-1-2 07:09:28

如何安装apache 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>
页: [1]
查看完整版本: 如何安装apache ivy