@lexi.ch home, code, stuff

My standard ANT build script 04.11.2011

<?xml version="1.0" encoding="UTF-8"?>
<project name="jDirSize" default="all" basedir=".">
    <property name="src" value="src" />
    <property name="build.dir" value="build" />
    <property name="lib.dir" value="lib" />
    <property name="classes.dir" value="${build.dir}/classes" />
    <property name="jar.dir" value="${build.dir}/jar" />

    <property name="main-class" value="ch.alexi.jdirsize.main.MainGui" />

    <path id="classpath">
            <fileset id="libs" dir="${lib.dir}" includes="**/*.jar"/>
    </path>

    <target name="init">
        <mkdir dir="${classes.dir}"/>
        <mkdir dir="${lib.dir}"/>
        <mkdir dir="${jar.dir}"/>
    </target>

    <target name="clean" description="Removes build files">
        <echo>Cleaning up...</echo>
        <delete verbose="true">
            <fileset dir="${build.dir}"></fileset>
        </delete>
    </target>

    <target name="compile" depends="init">
        <javac srcdir="${src}" destdir="${classes.dir}"  classpathref="classpath" includeantruntime="false"></javac>
    </target>

  <target name ="makejar" depends="compile" description="Create a jar for the ${ant.project.name} project">
    <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
        <fileset refid="libs"/>
        <manifest>
            <attribute name="Main-Class" value="${main-class}"/>
        </manifest>
    </jar>
  </target>

    <target name="clean-build" depends="clean,makejar"/>

    <target name="run" depends="makejar">
            <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
    </target>

    <target name="all" depends="clean,compile,makejar" description="Clean and Build whole project">
        <echo>Clean and build whole project</echo>
    </target>
</project>