Created
April 24, 2011 19:04
-
-
Save rodrigodealer/939801 to your computer and use it in GitHub Desktop.
Ivy example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project name="hello-ivy" default="run" xmlns:ivy="antlib:org.apache.ivy.ant"> | |
<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 | |
================================= --> | |
<property name="ivy.install.version" value="2.2.0" /> | |
<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"> | |
<mkdir dir="${ivy.jar.dir}"/> | |
<!-- download Ivy from web site so that it can be used even without any special installation --> | |
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" | |
dest="${ivy.jar.file}" usetimestamp="true"/> | |
</target> | |
<target name="init-ivy" depends="download-ivy"> | |
<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> | |
<target name="resolve" description="--> retreive dependencies with ivy" depends="init-ivy"> | |
<ivy:retrieve/> | |
</target> | |
<!-- ================================= | |
target: 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one | |
or more contributor license agreements. See the NOTICE file | |
distributed with this work for additional information | |
regarding copyright ownership. The ASF licenses this file | |
to you under the Apache License, Version 2.0 (the | |
"License"); you may not use this file except in compliance | |
with the License. You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, | |
software distributed under the License is distributed on an | |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
KIND, either express or implied. See the License for the | |
specific language governing permissions and limitations | |
under the License. | |
--> | |
<ivy-module version="2.0"> | |
<info organisation="org.apache" module="hello-ivy"/> | |
<dependencies> | |
<dependency org="commons-lang" name="commons-lang" rev="2.0"/> | |
<dependency org="commons-cli" name="commons-cli" rev="1.0"/> | |
</dependencies> | |
</ivy-module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment