| <?xml version="1.0" encoding="utf-8"?> |
| <!-- =================================================================== |
| |
| Build file for XPath Api |
| Sample usage: build javacc test -Dtest.expr="a/b /a/b /a|b" |
| |
| Setup instructions: |
| Before running an Ant build, you must |
| |
| - set the JAVA_HOME environment variable to the JDK root directory |
| |
| Build Instructions: |
| To build, run |
| ant [antoptions] [targets] |
| in the directory where this file is located; you should also be |
| able to use an installation of Ant v1.4.1 or later. |
| |
| build -projecthelp will show a list of supported targets. |
| |
| Developers: include a description="" attribute in all user-callable targets. |
| |
| Authors: |
| Shane Curcuru <shane_curcuru@lotus.com> |
| Scott Boag <scott_boag@us.ibm.com> |
| Lionel Villard <villard@us.ibm.com> |
| |
| Copyright: |
| Copyright (c) 1999-2003 The Apache Software Foundation. |
| $Id$ |
| ==================================================================== --> |
| |
| <project name="XPathAPI" default="javacc" basedir="."> |
| <property name="year" value="2003"/> |
| |
| <property name="version" value="0.5"/> |
| |
| <property name="build.dir" value="../build"/> |
| <property name="build.classes" value="${build.dir}/classes"/> |
| <property name="build.debug" value="on"/> |
| |
| <!-- Note bin.dir assumes we're using Xalan's checked-in copy of ant.jar --> |
| <property name="bin.dir" value="${ant.home}/bin"/> |
| <property name="jarfilename" value="xpath.jar"/> |
| |
| <property name="spec" value="xpath"/> |
| <property name="grammar.dir" value="grammar"/> |
| <property name="tree.xsl" value="${grammar.dir}/etree.xsl"/> |
| |
| <property name="src.dir" value="src2"/> |
| <property name="xpath.dir" value="org/apache/xpath"/> |
| <property name="xml.dir" value="org/apache/xml"/> |
| <property name="parser.dir" value="${src.dir}/${xpath.dir}/impl/parser"/> |
| <property name="parser.package" value="org.apache.xpath.impl.parser"/> |
| |
| <property name="test.class" value="org.apache.xpath.test.TestAST"/> |
| <property name="test.expr" value=""/> |
| |
| <property name="docs.dir" value="build/docs"/> |
| |
| |
| <path id="classpath"> |
| <!-- This should include all .jars needed to compile, including |
| a checked-in copy of xalan.jar and the JavaCC.zip file --> |
| <fileset dir="${bin.dir}" includes="*.jar"/> |
| <fileset dir="${bin.dir}" includes="*.zip"/> |
| </path> |
| |
| <path id="test.classpath"> |
| <path refid="classpath" /> |
| <fileset dir="${build.dir}" includes="*.jar"/> |
| </path> |
| |
| <path id="docs.class.path"> |
| <pathelement location="${build.dir}/${jarfilename}" /> |
| <pathelement path="${classpath}" /> |
| </path> |
| |
| <target name="clean" |
| description="Clean up classfiles and ${jarfilename}"> |
| <delete dir="${build.classes}"/> |
| <delete file="${build.dir}/${jarfilename}"/> |
| </target> |
| |
| <target name="clean-gen" depends="clean" |
| description="Clean up generated files as well as compiled ones"> |
| <delete file="${grammar.dir}/custom-xpath-grammar.xml"/> |
| <delete file="${parser.dir}/xpath-grammar.jj"/> |
| <delete file="${parser.dir}/xpath-grammar.jjt"/> |
| <delete> |
| <fileset dir="${parser.dir}" includes="XPath.java,XPathConstants.java,XPathTreeConstants.java,XPathTokenManager.java,XPathVisitor.java"/> |
| </delete> |
| </target> |
| |
| <target name="init"> |
| <echo message="Preset classpath is ${java.class.path}; ant.home is ${ant.home}"/> |
| <mkdir dir="${build.classes}"/> |
| <mkdir dir="${parser.dir}"/> |
| </target> |
| |
| <!-- ==== Code generation targets ==== --> |
| <target name="gen-grammar" depends="init" |
| description="[1]Use style task to turn grammar into jjt files"> |
| |
| <!-- Transform spec-defined xpath-grammar.xml into our custom-xpath-grammar.xml --> |
| <style style="${grammar.dir}/customize.xsl" in="${grammar.dir}/xpath-grammar.xml" |
| out="${grammar.dir}/custom-xpath-grammar.xml" force="yes" extension=".xml" |
| destdir="${grammar.dir}" classpathref="classpath" /> |
| |
| <!-- Transform our custom-xpath-grammar.xml into jjtree input xpath-grammar.jjt --> |
| <style style="${tree.xsl}" in="${grammar.dir}/custom-xpath-grammar.xml" |
| out="${parser.dir}/xpath-grammar.jjt" force="yes" extension=".jjt" |
| destdir="${spec}" classpathref="classpath" > |
| <param name="spec" expression="${spec}"/> |
| <param name="package-name" expression="${parser.package}"/> |
| </style> |
| </target> |
| |
| <target name="jjtree" depends="gen-grammar" |
| description="[2]Use JJTree to create tree sources"> |
| <!-- JJTree converts .jjt file into .jj file for input to javacc --> |
| <jjtree target="${parser.dir}/xpath-grammar.jjt" |
| javacchome="${bin.dir}" |
| outputdirectory="${parser.dir}" |
| static="false"/> |
| </target> |
| |
| <target name="javacc" depends="jjtree" |
| description="[3]Compile compile the tree sources"> |
| <!-- javacc converts .jj file into source .java files --> |
| <javacc target="${parser.dir}/xpath-grammar.jj" |
| javacchome="${bin.dir}" |
| debugtokenmanager="${debug}" |
| debugparser="${debug}" |
| sanitycheck="true" |
| static="false" |
| unicodeinput="${unicodeinput}" |
| javaunicodeescape="${unicodeinput}" |
| outputdirectory="${parser.dir}"/> |
| </target> |
| |
| <!-- ==== Code compilation and jar targets ==== --> |
| <target name="compile" depends="init" |
| description="[4]Compile all sources, including generated parser"> |
| <javac srcdir="${src.dir}" destdir="${build.classes}" debug="${build.debug}"> |
| <classpath refid="classpath"/> |
| </javac> |
| </target> |
| |
| <target name="jar" depends="compile" |
| description="[5]Jar standalone XPath engine into ${jarfilename}"> |
| <jar jarfile="${build.dir}/${jarfilename}"> |
| <fileset dir="${build.classes}" |
| includes="${xpath.dir}/**,${xml.dir}/**,${xpath.dir}/test/TestSamples.xml"/> |
| </jar> |
| </target> |
| |
| <target name="test" depends="jar" |
| description="[last]Run a simple test of XPath AST creation"> |
| <java fork="yes" classname="${test.class}" > |
| <classpath refid="test.classpath" /> |
| <arg line="${test.expr}"/> |
| </java> |
| </target> |
| |
| <target name="exportsrc" depends="jar" |
| description="Create exportable files for inclusion in other projects (experimental!)"> |
| <zip zipfile="${build.dir}/xpath-src.zip" > |
| <zipfileset dir="${src.dir}"> |
| </zipfileset> |
| </zip> |
| </target> |
| |
| <!-- ==== Documentation targets ==== --> |
| |
| <target name="apidocs" depends="jar" description="[6]Build API documentation"> |
| <mkdir dir="${docs.dir}"/> |
| <javadoc sourcepath="${src.dir}" destdir="${docs.dir}" |
| public="true" |
| packagenames="org.apache.xml,org.apache.xpath.*,org.apache.xpath.impl.*" |
| author="true" |
| version="true" |
| use="true" |
| windowtitle="XPath API" |
| doctitle="XPath API 2.0 Version ${version}" |
| bottom="Copyright © ${year} Apache XML Project. All Rights Reserved."> |
| <classpath refid="docs.class.path" /> |
| <group title="Namespace Support" packages="org.apache.xml"/> |
| <group title="XPath Public API" packages="org.apache.xpath:org.apache.xpath.expression"/> |
| <group title="XPath Implementation API" packages="org.apache.xpath.datamodel:org.apache.xpath.impl*"/> |
| </javadoc> |
| </target> |
| |
| </project> |