<project name="depending" default="run" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
    <!-- some variables used -->
    <property name="lib.dir" value="${basedir}/lib" />
    <property name="build.dir" value="${basedir}/build" />
    <property name="classes.dir" value="${build.dir}/classes" />
    <property name="src.dir" value="${basedir}/src" />

    <!-- ivy properties used -->
    <property name="ivy.conf.dir" value="../config" />
    <property file="${ivy.conf.dir}/ivyconf.properties" />
    
    <!-- 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="${classes.dir}" />
    </path>
    <!-- - - - - - - - - - - - - - - - - - 
          target: configure                      
         - - - - - - - - - - - - - - - - - -->
    <target name="configure">
        <ivy:configure file="${ivy.conf.dir}/ivyconf.xml" />
    </target>
    
    <!-- ================================= 
          target: resolve              
         ================================= -->
    <target name="resolve" depends="configure" description="--> retreive dependencies with ivy">
        <ivy:retrieve />
    </target>
    
    <!-- ================================= 
          target: report              
         ================================= -->
    <target name="report" depends="resolve" description="--> generates a report of dependencies">
        <ivy:report todir="${build.dir}" dot="true"/>
    </target>
    
    <!-- ================================= 
          target: gen-graph
         ================================= -->
    <target name="gen-graph" depends="report" description="--> generates a graph of dependencies (requires dot in your path - see http://www.graphviz.org/)">
    	<property name="dot.file" value="${build.dir}/jayasoft-depending-default.dot" />
    	<property name="ivygraph.output.file" value="${build.dir}/graph.png" />
    	<exec executable="dot">
    	    <arg line="-T png -o ${ivygraph.output.file} ${dot.file}" />
    	</exec>
    </target>
    
    <!-- ================================= 
          target: compile              
         ================================= -->
    <target name="compile" depends="resolve" description="--> description">
        <mkdir dir="${classes.dir}" />
        <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" />
    </target>
    
    <!-- ================================= 
          target: run
         ================================= -->
    <target name="run" depends="clean, compile" description="--> compile and run the project">
        <java classpathref="run.path.id" classname="depending.Main"/>
    </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>
</project>
