Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
165 lines (136 sloc) 6.44 KB
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
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
<project name="hello-ivy" default="run"
<!-- Sonar task def -->
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml" />
<property name="" value="http://localhost:9000" />
<property name="sonar.jdbc.url" value="jdbc:derby://localhost:9527/sonar" />
<property name="sonar.jdbc.driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
<property name="sonar.jdbc.username" value="sonar" />
<property name="sonar.jdbc.password" value="sonar" />
<!-- 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="">
<fileset dir="${lib.dir}" />
<path id="">
<path refid="" />
<path location="${build.dir}" />
<!-- =================================
target: resolve
================================= -->
<target name="resolve" description="--> retreive dependencies with ivy">
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
<!-- =================================
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="" />
<property name="msg" value="hello ivy !"/>
<java classpathref="" classname="example.Hello">
<arg value="-message"/>
<arg value="${msg}"/>
<!-- =================================
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" />
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<ivy:cleancache />
<!-- target: jar -->
<target name="jar">
<mkdir dir="${build.dir}/jar"/>
<jar destfile="${build.dir}/jar/Hello.jar" basedir="${build.dir}">
<attribute name="Main-Class" value="example.Hello"/>
<!-- target: deploy -->
<target name="deploy" depends="clean,resolve,jar" description="--> deploy artifact to maven repo">
<artifact:pom id="mypom" groupId="org.apache" artifactId="hello-ivy" version="1.0-SNAPSHOT" name="Example Ant/Ivy project.">
<license name="apache" url=""/>
<artifact:writepom pomRefId="mypom" file="${build.dir}/pom.xml"/>
<artifact:install file="${build.dir}/jar/hello.jar">
<pom refid="mypom" file="${build.dir}/pom.xml"/>
<artifact:install-provider artifactId="wagon-http" version="1.0-beta-2"/>
<artifact:deploy file="${build.dir}/jar/hello.jar">
<remoteRepository id="artifactory" url="http://localhost:8081/artifactory/libs-snapshot-local"/>
<pom refid="mypom" file="${build.dir}/pom.xml"/>
<!-- Fetch Ivy -->
<property name="ivy.install.version" value="2.2.0" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
<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="${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
<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. -->
<ivy:settings file="${ivy.settings.dir}/ivysettings.xml" refid="ivy.classpath" />
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
<target name="sonar" depends="report" >
<!-- list of mandatories Sonar properties -->
<property name="sonar.sources" value="src" />
<sonar:sonar key="org.apache:hello-ivy" version="1.0-SNAPSHOT" xmlns:sonar="antlib:org.sonar.ant"/>