Skip to content

Instantly share code, notes, and snippets.

@rhiguchi
Created June 24, 2012 04:59
Show Gist options
  • Save rhiguchi/2981711 to your computer and use it in GitHub Desktop.
Save rhiguchi/2981711 to your computer and use it in GitHub Desktop.
Ant で Ivy の jar をダウンロードさせて、その jar からタスクを定義する ref: http://qiita.com/items/21e5370ffa178bb19bc9
<project xmlns:ivy="antlib:org.apache.ivy.ant">
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ivy2" />
<property name="ivy.install.dir" value="${ivy.home}/lib" />
<property name="ivy.install.dest" value="${ivy.install.dir}/ivy.jar" />
<target name="-check-ivy-user-installed" description="check ivy jar file existence on user's ivy home">
<available file="${ivy.install.dest}" property="ivy.install.dest.exisits" />
</target>
<target name="-taskdef-user-ivy" depends="-check-ivy-user-installed" if="ivy.install.dest.exisits">
<path id="ivy.install.path">
<fileset dir="${ivy.install.dir}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.install.path"/>
</target>
<target name="install-ivy" description="Download Ivy jar file to ivy home">
<property name="ivy.install.version" value="2.2.0" />
<property name="ivy.install.src"
value="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" />
<mkdir dir="${ivy.install.dir}" />
<get src="${ivy.install.src}" dest="${ivy.install.dest}" usetimestamp="true"/>
</target>
<target name="clean-ivy" description="Delete Ivy jar file from ivy home">
<delete file="${ivy.install.dest}" />
</target>
<!-- sample task to use user ivy -->
<target name="resolve" description="Resolve dependency" depends="-taskdef-user-ivy">
<ivy:resolve />
</target>
</project>
ant install-ivy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment