<project name="Simple Tree Parser" default="dist" basedir="."> <description> Example for a simple tree parser. </description> <property name="project.name" value="SimpleTreeParser" /> <!-- program version --> <property name="version" value="1.01" /> <!-- set global properties for this build --> <property name="build" location="."/> <property name="src" location="src"/> <property name="classes" location="classes"/> <property name="dist" location="dist" /> <property name="doc" location="docs/api"/> <property name="grammar" location="grammar"/> <property name="package" value=""/> <!-- where to write/find token files --> <property name="token.lib" location="${src}/${package}" /> <!-- antlr options --> <property name="profile" value="false" /> <property name="report" value="true" /> <property name="multithreaded" value="true" /> <target name="init" depends="antlr_classpath"> <!-- Create the time stamp --> <tstamp /> <!-- Create the build directory structure used by compile --> <mkdir dir="${grammar}" /> <mkdir dir="${src}/${package}" /> <mkdir dir="${classes}" /> <mkdir dir="${classes}/META-INF" /> <mkdir dir="${dist}" /> <mkdir dir="${doc}/${package}" /> </target> <!-- Check if Antlr is in classpath --> <target name="antlr_classpath"> <whichresource property="antlr.in.classpath" class="org.antlr.Tool" /> <fail message="ANTLR3 library not found via CLASSPATH"> <condition> <not> <isset property="antlr.in.classpath"/> </not> </condition> </fail> <echo>ANTLR3 found via CLASSPATH</echo> </target> <macrodef name="antlr3"> <attribute name="grammar.name"/> <attribute name="package" default="${package}"/> <attribute name="verbose" default="True"/> <attribute name="profile" default="False"/> <attribute name="multithreaded" default="True"/> <sequential> <echo message="antlr ${grammar}/@{grammar.name}" /> <antlr:ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr" target="${grammar}/@{grammar.name}" outputdirectory="${src}/@{package}" libdirectory="${src}/@{package}" multithreaded="@{multithreaded}" verbose="@{verbose}" depend="${depend}" profile="@{profile}"> </antlr:ant-antlr3> </sequential> </macrodef> <target name="SimpleC" depends="init"> <antlr3 grammar.name="SimpleC.g"/> </target> <target name="SimpleCWalker" depends="init"> <antlr3 grammar.name="SimpleCWalker.g"/> </target> <target name="compile" depends="SimpleC, SimpleCWalker" description="compile"> <!-- Compile the java code from ${src} into ${classes} --> <javac debug="true" srcdir="${src}" destdir="${classes}" target="1.6" listfiles="Yes" deprecation="Yes" includeantruntime="False"> <compilerarg value="-Xlint:unchecked"/> <classpath> <pathelement path="${java.class.path}"/> </classpath> </javac> </target> <target name="manifest"> <manifest file="${classes}/META-INF/MANIFEST.MF"> <attribute name="Main-Class" value="${package}.Main" /> </manifest> </target> <target name="dist" depends="compile, manifest" description="generate for distribution"> <jar jarfile="${dist}/lib/${project.name}.jar" basedir="${classes}" manifest="${classes}/META-INF/MANIFEST.MF"/> </target> <target name="doc" description="generate documentation"> <javadoc destdir="${doc}" author="true" version="true" use="true" windowtitle="${project.name}" sourcefiles="${src}/${package}/*.java" Protected="All" Private="All" Public="All" Locale="de" linksource="yes" breakiterator="Yes"> <classpath> <pathelement path="${java.class.path}"/> </classpath> </javadoc> </target> <target name="clean" description="clean up"> <delete> <fileset dir="${src}" includes="**/*.class,**/*.tokens,**/*.g*" /> <fileset dir="${classes}" /> <fileset dir="${dist}" includes="**/*.jar" /> <fileset dir="${doc}" /> </delete> </target> <target name="redo" depends="init"> <touch> <fileset dir="${grammar}" includes="*.g"/> </touch> </target> <target name="all" depends="init, clean, redo, dist, doc" description="do all"/> </project>