Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
Created August 7, 2012 10:46
Show Gist options
  • Save snipsnipsnip/3284453 to your computer and use it in GitHub Desktop.
Save snipsnipsnip/3284453 to your computer and use it in GitHub Desktop.
ant build.xml for netbeans with ivy integration
<?xml version="1.0" encoding="UTF-8"?>
<project name="JavaApplication2" default="default" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<description>Builds, tests, and runs the project JavaApplication2.</description>
<import file="nbproject/build-impl.xml"/>
<property name="ivy.install.version" value="2.3.0-rc1" />
<property name="ivy.jar.dir" value="${basedir}/ivy" />
<property name="ivy.cache.dir" value="${basedir}/ivy" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="ivy.lib" value="${basedir}/lib" />
<property name="ivy.settings.location" value="${basedir}/ivysettings.xml" />
<target name="-check-ivy">
<available file="${ivy.jar.file}" property="ivy.skip.download"/>
</target>
<target name="-download-ivy" unless="ivy.skip.download" depends="-check-ivy">
<mkdir dir="${ivy.jar.dir}"/>
<echo message="installing ivy..."/>
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="-load-ivy-tasks" depends="-download-ivy">
<path id="ivy.lib.path">
<pathelement location="${ivy.jar.file}"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="download-deps" depends="-load-ivy-tasks"
description="Download dependent libraries.">
<ivy:resolve/>
<ivy:retrieve/>
<pathconvert property="ivy.classpath.computed" dirsep="/" pathsep=":">
<path>
<fileset dir="${ivy.lib}" includes="*.jar"/>
</path>
<map from="${basedir}${file.separator}" to=""/>
</pathconvert>
<propertyfile file="${basedir}/nbproject/project.properties">
<entry operation="=" key="ivy.classpath" value="${ivy.classpath.computed}"/>
</propertyfile>
</target>
<target name="clean-deps" description="Clean downloaded libraries.">
<delete dir="${ivy.lib}"/>
</target>
<target name="clean-ivy" depends="clean-deps" description="Clean ivy.">
<delete dir="${ivy.jar.dir}"/>
<ivy:cleancache/>
<propertyfile file="${basedir}/nbproject/project.properties">
<entry operation="=" key="ivy.classpath" value=""/>
</propertyfile>
</target>
<target name="-use-ivy-junit" depends="download-deps" unless="netbeans.home">
<property name="libs.junit_4.classpath" value="${ivy.lib}/junit-4.10.jar"/>
</target>
<target name="-pre-compile" depends="download-deps"/>
<target name="-pre-compile-single" depends="download-deps"/>
<target name="-pre-init" depends="-use-ivy-junit"/>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
<info module="JavaApplication2" organisation="com.github.gist" revision="0.1"/>
<configurations defaultconfmapping="build->*">
<conf name="build" description="normal build"/>
<conf name="test" extends="build" visibility="private" description="testing build"/>
</configurations>
<publications>
<artifact name="JavaApplication2" type="jar" conf="build" ext="jar"/>
</publications>
<dependencies>
<dependency org="com.google.guava" name="guava" rev="13.0"/>
<dependency org="junit" name="junit" rev="4.10" conf="test->*"/>
</dependencies>
</ivy-module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment