安裝ivy主要有兩種方式,手工安裝或者自動安裝。
1) 手工安裝
從
這里下載你想要的版本,在任何你想的地方解開下載的zip文件,并復制ivy的jar文件到你的ant的lib目錄(ANT_HOME/lib).
如果你使用ant 1.6.0或者更高,你可以簡單的到src/example/hello-ivy 目錄并運行ant: 如果構建成功,你就成功的安裝了ivy!
如果你使用ant1.5.1或者更高,你不得不修改示例里面的build文件。
- 為ivy任務增加任務定義:
<taskdef name="ivy-configure" classname="org.apache.ivy.ant.IvyConfigure"/>
<taskdef name="ivy-resolve" classname="org.apache.ivy.ant.IvyResolve"/>
<taskdef name="ivy-retrieve" classname="org.apache.ivy.ant.IvyRetrieve"/>
<taskdef name="ivy-publish" classname="org.apache.ivy.ant.IvyPublish"/>
- 將 ivy:xxx 任務替換為 ivy-xxx
你現在可以運行build,如果構建成功,你就成功的安裝了ivy!
如果構建沒有成功,檢查
FAQ看是ivyrep解析器的什么問題。
ivy依賴
ivy的兩個二進制版本中有一個不包含可選依賴。為了通過使用ivy下載他們,你所需要做的是運行在分發包中提供的ant構建文件。這將使用ivy自己來下載依賴。然后你可以在ivy的lib目錄下看到按照配置被組織的ivy可選依賴(查閱ivy.xml來得知配置的詳情)。
2) 自動安裝
如果你想在僅僅在你的ant構建腳本中使用ivy,并且在你構建的時候有internet連接,你可以從自動這個站點下載ivy并使用下載的版本,使用這個簡單的構建片段:
<property name="ivy.install.version" value="2.0.0-beta1" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ant" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<target name="download-ivy" unless="offline">
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://www.apache.org/dist/ant/ivy/${ivy.install.version}/ivy.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="download-ivy">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
然后需要做的僅僅是在你的使用ivy的目標里面增加目標init-ivy的依賴,并增加ivy命名空間到你的構建腳本。關于這個的更多細節請看自包含的示例
go-ivy.