<?xml version="1.0" encoding="utf-8"?> <!--- @author: Saleem Abdulrasool <compnerd@gentoo.org> @date: 5/9/2005 @modified: 10/23/2005 @revision: 1.0_alpha @notes: Call using the following: ant -f build.xml -Dproject.name=${project name} -Dpackage.name=${package name} It will create a jar called ${project.name} and will try to generate javadoc for the comma delimited list ${package.name} (fex org.gentoo.*,org.compnerd.*) Define classpath.broken (-Dclasspath.broken=1) if you need a top level Manifest. All paths can be overridden by defining the values in build.properties in the same directory as this build file. --> <project name="Gentoo_Builder" default="jar" basedir="."> <property name="src" value="src"/> <property name="build" value="build"/> <property name="dist" value="dist"/> <property name="lib" value="lib"/> <property name="pkg" value="${package.name}"/> <property name="jar" value="${project.name}.jar"/> <!-- Override any defined properties --> <property file="build.properties"/> <available file="${lib}" type="dir" property="libdir.exists"/> <target name="init"> <tstamp/> <mkdir dir="${build}"/> <mkdir dir="${dist}"/> <mkdir dir="${dist}/doc"/> <!-- Check if we need to modify the classpath --> <antcall target="if-libdir"/> </target> <!-- If the directory exists, append to classpath --> <target name="if-libdir" if="libdir.exists"> <property name="classpath" value="${classpath}:${lib}"/> <classpath> <pathelement path="${classpath}"/> <fileset dir="${lib}"> <include name="**/*.jar"/> </fileset> </classpath> </target> <target name="compile" depends="init"> <javac srcdir="${src}" destdir="${build}" classpath="${classpath}"/> </target> <target name="manifest" depends="init"> <manifest file="${build}/MANIFEST.MF" mode="update"> <attribute name="Built-By" value="Gentoo Portage"/> </manifest> </target> <target name="jar" depends="compile,manifest"> <jar destfile="${dist}/${jar}" manifest="${build}/MANIFEST.MF"> <fileset dir="${build}"> <exclude name="MANIFEST.MF" unless="classloader.broken"/> </fileset> <fileset dir="${src}" includes="**/*.properties" /> <metainf dir="${src}/META-INF" /> </jar> </target> <target name="javadoc" depends="compile"> <javadoc sourcepath="${src}" destdir="${dist}/doc" packagenames="${pkg}"> <classpath path="${classpath}"/> </javadoc> </target> <target name="clean"> <delete dir="${build}"/> <delete dir="${dist}"/> </target> </project>