Source

jython / build.xml

<!-- Copyright 2000 Dj Walker-Morgan -->

<project name="jython" default="jar" basedir=".">

    <!--
      This propery should be specified in the ant.property file
      property name="javaccHome2" value="/opt/javacc2.0/bin/lib"
    -->

    <!-- Give users a change to override editing this file. -->
    <property file="ant.properties" />

    <!-- =================================================================== -->
    <!-- Classpaths                                                          -->
    <!-- =================================================================== -->
    <path id="main.classpath">
        <pathelement path="${readline.jar}"/>
        <pathelement path="${servlet.jar}"/>
        <pathelement path="${informix.jar}"/>
        <pathelement path="${oracle.jar}"/>
        <pathelement path="${mysql.jar}"/>
        <pathelement path="${postgresql.jar}"/>
        <pathelement path="${jndi.jar}"/>
        <pathelement path="${jdbc.jar}"/>
        <pathelement path="${java.class.path}"/>
        <pathelement location="${build.classes}"/>
    </path>

    <target name="init">

        <property name="sourceDir" value="${basedir}" />
        <property name="outputDir" value="${basedir}/build" />
        <property name="apidocDir" value="${basedir}/Doc/javadoc" />
        <property name="debug" value="off" />
        <property name="optimize" value="on" />

        <available property="java2collection.present"
            classname="java.util.List"
        />
        <available property="threadlocal.present"
            classname="java.lang.ThreadLocal"
        />
        <available property="secureclassloader.present"
            classname="java.security.SecureClassLoader"
        />
        <available property="java2accessible.present"
            classname="java.lang.reflect.AccessibleObject"
        />
        <available property="weakref.present"
            classname="java.lang.ref.WeakReference"
        />
        <available property="servlet.present" 
            classname="javax.servlet.Servlet"
            classpath="${servlet.jar}"
        />

        <available property="readline.present"
            classname="org.gnu.readline.Readline"
            classpath="${readline.jar}"
        />

        <available property="informix.present"
            classname="com.informix.jdbc.IfxDriver"
            classpath="${informix.jar}"
        />
        <available property="mysql.present"
            classname="org.gjt.mm.mysql.Driver"
            classpath="${mysql.jar}"
        />
        <available property="postgresql.present"
            classname="org.postgresql.Driver"
            classpath="${postgresql.jar}"
        />
        <available property="oracle.present"
            classname="oracle.jdbc.driver.OracleDriver"
            classpath="${oracle.jar}"
        />
        <available property="jndi.present"
            classname="javax.naming.Context"
            classpath="${jndi.jar}"
        />
        <available property="javax.sql.present"
            classname="javax.sql.DataSource"
            classpath="${jdbc.jar}"
        />

        <echo>--- Build environment for ${ant.project.name} ---</echo>
        <echo>--- Flags (Note: If the {property name} is displayed,</echo>
        <echo>--- then the component is not present)</echo>
        <echo/>
        <echo>--- Optional Libraries ---</echo>
        <echo>java2 coll  = ${java2collection.present}</echo>
        <echo>servlet     = ${servlet.present}</echo>
        <echo>readline    = ${readline.present}</echo>
        <echo>oracle      = ${oracle.present}</echo>
        <echo>informix    = ${informix.present}</echo>
        <echo>mysql       = ${mysql.present}</echo>
        <echo>postgresql  = ${postgresql.present}</echo>
        <echo>jndi        = ${jndi.present}</echo>
        <echo>jdbc        = ${javax.sql.present}</echo>

    </target>

    <target name="clean" depends="init">
        <delete dir="${outputDir}/" />
        <property name="parser" value="${sourceDir}/org/python/parser" />
        <delete file="${parser}/python.jj" />
        <delete file="${parser}/PythonGrammar.java" />
        <delete file="${parser}/PythonGrammarConstants.java" />
        <delete file="${parser}/PythonGrammarTokenManager.java" />
        <delete file="${parser}/PythonGrammarTreeConstants.java" />
        <delete file="${parser}/Node.java" />
        <delete file="${parser}/Token.java" />
        <delete file="${parser}/ASCII_CharStream.java" />
        <delete file="${parser}/JJTPythonGrammarState.java" />
    </target>

    <target name="prepare" depends="init">
        <mkdir dir="${outputDir}" />
    </target>

    <target name="tree" depends="prepare">
        <jjtree
            javacchome="${javaccHome2}"
            target="org/python/parser/python.jjt"
            outputdirectory="org/python/parser/"
        />
    </target>

    <target name="parser" depends="tree">
        <javacc
            javacchome="${javaccHome2}"
            target="org/python/parser/python.jj"
            outputdirectory="org/python/parser/"
        />
        <!-- Damn! The task above assumes that the generated name
             is basename of the input file. So we fake it to be the case-->
        <touch file="org/python/parser/python.java" />
    </target>

    <target name="compile" depends="prepare,parser">
        <javac
            srcdir="${sourceDir}/"
            destdir="${outputDir}/"
            debug="${debug}"
            optimize="${optimize}">
            <include name="org/**"/>
            <exclude name="org/python/parser/python.java"/>

            <include name="com/ziclix/python/sql/**"
                     if="java2collection.present"/>

            <exclude name="**/CollectionProxy2.java"
                     unless="java2collection.present"/>
            <exclude name="**/Java2Accessibility.java"
                     unless="java2accessible.present"/>
            <exclude name="**/BytecodeLoader2.java"
                     unless="secureclassloader.present"/>
            <exclude name="**/ThreadStateMapping2.java"
                     unless="threadlocal.present"/>

            <exclude name="**/InternalTables2.java"
                     unless="weakref.present"/>
            <exclude name="**/WeakInternalTables.java"
                     unless="weakref.present"/>
            <exclude name="**/AutoInternalTables.java"
                     unless="weakref.present"/>
            <exclude name="**/SoftIInternalTables.java"
                     unless="weakref.present"/>
            <exclude name="**/_weakref.java"
                     unless="weakref.present"/>

            <exclude name="**/PyServlet.java" unless="servlet.present"/>
            <exclude name="**/ReadlineConsole.java"
                     unless="readline.present"/>

            <exclude name="**/handler/InformixDataHandler.java"
                     unless="informix.present"/>
            <exclude name="**/handler/MySQLDataHandler.java"
                     unless="mysql.present"/>
            <exclude name="**/handler/OracleDataHandler.java"
                     unless="oracle.present"/>
            <exclude name="**/handler/PostgresqlDataHandler.java"
                     unless="postgresql.present"/>
            <exclude name="**/connect/Lookup.java" unless="jndi.present"/>
            <exclude name="**/connect/Lookup.java" unless="javax.sql.present"/>
            <exclude name="**/connect/Connectx.java"
                     unless="javax.sql.present"/>
            <classpath refid="main.classpath"/>
        </javac>

        <javac
            srcdir="${sourceDir}/Lib"
            includes="jxxload_help/**"
            destdir="${outputDir}/"
            debug="${debug}"
            optimize="${optimize}"
        />

       <copy file="org/python/modules/ucnhash.dat"
             todir="${outputDir}/org/python/modules" />

       <copy todir="${outputDir}/com">
           <fileset dir="${sourceDir}/com">
              <include name="**/*.properties" if="java2collection.present"/>
           </fileset>
       </copy>

    </target>

    <target name="jar" depends="compile">
        <jar jarfile="jython.jar"
             basedir="${outputDir}"
             includes="**/*.class,**/ucnhash.dat,**/*.properties" />
    </target>

    <target name="doc" depends="init">
        <delete>
            <fileset dir="Doc" includes="*.html" />
        </delete>
        <!-- Create .html files in Doc -->
        <execon executable="${python.home}/python" dir="Doc">
            <arg line="${ht2html.dir}/ht2html.py"/>
            <arg line="-s JPyLocalGenerator"/>
            <fileset dir="Doc">
                <include name="*.ht" />
            </fileset>
        </execon>
    </target>

    <target name="javadoc" depends="compile">
        <delete dir="${apidocDir}" />
        <mkdir dir="${apidocDir}" />
        <javadoc sourcepath="${sourceDir}"
                 destdir="${apidocDir}"
                 public="true"
                 packagenames="org.python.core,
                               org.python.util,
                               com.ziclix.python.sql"
                 windowtitle="Jython API documentation"
                 bottom="&lt;a href='http://www.jython.org'
                         target='_top'>Jython homepage&lt;/a>"
        />
    </target>

    <target name="installXML" depends="init">
        <!-- Set the configuration variables python.home and PyXmlHome
             in your ant.properties file -->
        <copy todir="${sourceDir}/Lib/xml">
            <fileset dir="${python.home}/Lib/xml" includes="__init__.py"/>
            <fileset dir="${PyXmlHome}/xml" includes="
                ns.py,
                sax/*.py,
                sax/drivers2/drv_xmlproc.py,
                sax/drivers2/__init__.py,
                utils/*.py,
                dom/*.py,
                dom/html/*.py,
                dom/ext/*.py,
                dom/ext/reader/__init__.py,
                dom/ext/reader/Sax*.py,
                parsers/__init__.py,
                parsers/xmlproc/*.py,
                "/>
        </copy>
    </target>

    <target name="all" depends="init,clean,prepare,parser,compile,jar"/>
</project>