<commit_before><?xml version="1.0"?>
<!--

  Copyright (c) 2004-2005, PostgreSQL Global Development Group

  Build file to allow ant (http://ant.apache.org/) to be used
  to build the PostgreSQL JDBC Driver.

  This file now requires Ant 1.4.1.  2002-04-18

  $PostgreSQL: pgjdbc/build.xml,v 1.65 2005/11/24 02:29:19 oliver Exp $

-->

<!DOCTYPE project [
  <!ENTITY jarfiles "postgresql.jar">
]>

<project name="postgresqlJDBC" default="all" basedir=".">

  <!-- set global properties for this build -->
  <property name="srcdir"  value="." />
  <property name="jardir"  value="jars" />
  <property name="builddir" value="build" />
  <property name="package" value="org/postgresql" />
  <property name="debug" value="on" />

  <!-- default build parameters are in build.properties, these may be
       overridden by local configuration settings in build.local.properties
  -->
  <property file="build.local.properties" />
  <property file="build.properties"/>

  <target name="check_versions">
    <condition property="jdbc2">
      <or>
        <equals arg1="${ant.java.version}" arg2="1.2"/>
        <equals arg1="${ant.java.version}" arg2="1.3"/>
      </or>
    </condition>
    <condition property="jdbc3">
        <equals arg1="${ant.java.version}" arg2="1.4"/>
    </condition>
    <condition property="jdbc3g">
	<equals arg1="${ant.java.version}" arg2="1.5"/>
    </condition>
    <condition property="jdbc3any">
      <or>
        <isset property="jdbc3" />
        <isset property="jdbc3g" />
      </or>
    </condition>

    <available property="datasource" classname="javax.sql.DataSource"/>
    <available property="ssl" classname="javax.net.ssl.SSLContext"/>
    <available property="junit" classname="junit.framework.Test"/>
    <available property="junit.task" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

    <condition property="jdbc2optionaltests">
      <and>
        <isset property="datasource"/>
        <isset property="junit"/>
      </and>
    </condition>

    <condition property="jdbc3tests">
      <and>
        <isset property="jdbc3any"/>
        <isset property="datasource"/>
        <isset property="junit"/>
      </and>
    </condition>
  </target>


  <!-- default target -->
  <target name="all">
    <antcall target="jar" />
  </target>


  <!-- create the jar file -->
  <target name="jar" depends="compile">
    <jar jarfile="${jardir}/postgresql.jar">
      <fileset dir="${builddir}">
        <include name="${package}/**/*.class" />
      </fileset>

      <fileset dir="${srcdir}">
        <include name="${package}/translation/*.class" />
      </fileset>
    </jar>
  </target>


  <target name="compile" depends="prepare,check_versions,driver">

    <available classname="org.postgresql.Driver" property="old.driver.present" />
    <fail message="Old driver was detected on classpath or in jre/lib/ext, please remove and try again." if="old.driver.present" />

    <javac classpath="${srcdir}" srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
      <!-- This is the core of the driver.  It is common for all versions. -->
       <include name="${package}/*.java" />
       <include name="${package}/core/**" />
       <include name="${package}/fastpath/**" />
       <include name="${package}/geometric/**" />
       <include name="${package}/largeobject/**" />
       <include name="${package}/util/**" />

       <!--      
       Each jdbcN subpackage is used only if the driver supports *at least* that
       revision of JDBC. That is, a JDBC2 build uses only jdbc2, a JDBC3 build
       uses both jdbc2 and jdbc3, etc.
  
       Within those subpackages, classes beginning with "JdbcN" are assumed to be
       the concrete implementations for JDBC version N and are built only if the
       driver supports *exactly* that version. For example, jdbc2/Jdbc2Statement.java
       is built only if the driver build is a JDBC2 build.
       -->
 
       <!-- jdbc2 subpackage -->
       <include name="${package}/jdbc2/**" if="jdbc2"/>
       <include name="${package}/jdbc2/**" if="jdbc3"/>
       <include name="${package}/jdbc2/**" if="jdbc3g"/>
       <exclude name="${package}/jdbc2/Jdbc2*.java" unless="jdbc2"/>
 
       <!-- jdbc3 subpackage -->
       <include name="${package}/jdbc3/Abstract*.java" if="jdbc3any" />
       <include name="${package}/jdbc3/PSQLSavepoint.java" if="jdcb3any" />
       <include name="${package}/jdbc3/PSQLParameterMetaData.java" if="jdbc3any" />

       
       <include name="${package}/jdbc3/Jdbc3Array.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3Blob.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3CallableStatement.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3Clob.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3Connection.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3DatabaseMetaData.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3PreparedStatement.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3ResultSet.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3ResultSetMetaData.java.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3Statement.java" if="jdbc3"/>

       <!-- jdbc3g subpackage -->
       <include name="${package}/jdbc3g/*.java" if="jdbc3g" />
       <exclude name="${package}/jdbc3g/Jdbc3g*.java" unless="jdbc3g" />

       <!-- ssl -->
       <include name="${package}/ssl/*.java" if="ssl" />

       <!-- datasource stuff -->
       <exclude name="${package}/jdbc2/optional/**" unless="datasource"/>
       <include name="${package}/jdbc3/Jdbc3ConnectionPool.java" if="jdbc3any" />
       <include name="${package}/jdbc3/Jdbc3PoolingDataSource.java" if="jdbc3any" />
       <include name="${package}/jdbc3/Jdbc3SimpleDataSource.java" if="jdbc3any" />

       <include name="${package}/ds/**/*.java" if="datasource" />

       <!-- XA stuff -->
       <include name="${package}/xa/*.java" if="jdbc3any" />

    </javac>
  </target>

  <target name="check_driver">
    <uptodate targetfile="${package}/Driver.java" property="driver.uptodate">
      <srcfiles dir=".">
      <include name="${package}/util/PSQLException.java.in"/>
      <include name="${package}/Driver.java.in"/>
      <include name="build.properties"/>
      <include name="build.local.properties" />
      </srcfiles>
    </uptodate>
  </target>

  <!--
    This generates Driver.java from Driver.java.in
    It's required for importing the driver version properties
  -->
  <target name="driver" depends="prepare,check_versions,check_driver"
          unless="driver.uptodate">
    <!-- determine the edition text -->
    <condition property="edition" value="JDBC2 Enterprise">
      <and>
        <available classname="javax.sql.DataSource" />
        <equals arg1="${jdbc2}" arg2="true"/>
      </and>
    </condition>
    <condition property="edition" value="JDBC2">
        <equals arg1="${jdbc2}" arg2="true"/>
    </condition>
    <condition property="edition" value="JDBC3">
        <equals arg1="${jdbc3}" arg2="true"/>
    </condition>
    <condition property="edition" value="JDBC3g">
    	<equals arg1="${jdbc3g}" arg2="true" />
    </condition>

    <!-- determine the connection class -->
    <condition property="connectclass" value="org.postgresql.jdbc2.Jdbc2Connection">
        <equals arg1="${jdbc2}" arg2="true"/>
    </condition>
    <condition property="connectclass" value="org.postgresql.jdbc3.Jdbc3Connection">
        <equals arg1="${jdbc3}" arg2="true"/>
    </condition>
    <condition property="connectclass" value="org.postgresql.jdbc3g.Jdbc3gConnection">
        <equals arg1="${jdbc3g}" arg2="true"/>
    </condition>

    <!-- Determine if we have Throwable.initCause() 
         if so we use it in org.postgresql.util.PSQLException
         instead of appending any nested exception to the message. -->
    <condition property="noInitCause" value="//">
      <equals arg1="${jdbc3any}" arg2="true" />
    </condition>
    
    <condition property="noInitCause" value="">
      <not><equals arg1="${jdbc3any}" arg2="true" /></not>
    </condition>

    <!-- determine the ssl status -->
    <condition property="ssl_config" value="">
        <equals arg1="${ssl}" arg2="true"/>
    </condition>
    <condition property="ssl_config" value="//">
        <not>
            <equals arg1="${ssl}" arg2="true"/>
        </not>
    </condition>
    <condition property="ssl_edition" value="SSL">
        <equals arg1="${ssl}" arg2="true"/>
    </condition>
    <condition property="ssl_edition" value="NO SSL">
        <not>
            <equals arg1="${ssl}" arg2="true"/>
        </not>
    </condition>

    <!-- Some defaults -->
    <filter token="MAJORVERSION" value="${major}" />
    <filter token="MINORVERSION" value="${minor}" />
    <filter token="VERSION" value="PostgreSQL ${fullversion} ${edition} with ${ssl_edition}" />
    <filter token="JDBCCONNECTCLASS" value="${connectclass}" />
    <filter token="DEF_PGPORT" value="${def_pgport}" />
    <filter token="SSL" value="${ssl_config}" />
    <filter token="NOINITCAUSE" value="${noInitCause}" />

     <fail unless="major" message="'major' undefined. Please follow the directions in README."/>
     <fail unless="minor" message="'minor' undefined. Please follow the directions in README."/>
     <fail unless="fullversion" message="'fullversion' undefined. Please follow the directions in README."/>
     <fail unless="def_pgport" message="'def_pgport' undefined. Please follow the directions in README."/>
     <fail unless="enable_debug" message="'enable_debug' undefined. Please follow the directions in README."/>
 
    <!-- Put a check for the current version here -->

    <!-- now copy and filter the file -->
    <copy file="${package}/Driver.java.in"
          overwrite="true"
          tofile="${package}/Driver.java"
          filtering="yes" />
    <copy file="${package}/util/PSQLException.java.in"
          overwrite="true"
          tofile="${package}/util/PSQLException.java"
          filtering="yes" />

    <echo message="Configured build for the ${edition} edition driver with ${ssl_edition}" />
  </target>


  <!-- Prepares the build directory -->
  <target name="prepare">
    <!-- use the enable_debug option from configure -->
    <condition property="debug" value="on">
      <and>
        <equals arg1="${enable_debug}" arg2="yes" />
      </and>
    </condition>
    <mkdir dir="${builddir}" />
    <mkdir dir="${jardir}" />
  </target>


  <!-- This target removes any class files from the build directory -->
  <target name="clean">
    <delete quiet="true" dir="${builddir}" />
    <delete quiet="true" dir="${jardir}" />
    <delete quiet="true" file="${package}/Driver.java" />
    <delete quiet="true" file="${package}/util/PSQLException.java" />
  </target>

  <!-- This compiles and executes the JUnit tests -->

  <!-- defaults for the tests - override these if required -->
  <property name="server" value="localhost" />
  <property name="port" value="${def_pgport}" />
  <property name="database" value="test" />
  <property name="username" value="test" />
  <!-- Password must be something.  Doesn't matter if trust is used! -->
  <property name="password" value="password" />
  <property name="preparethreshold" value="0" />
  <property name="loglevel" value="0" />

  <!-- The tests now build to a separate directory and jarfile from the
       driver build, to ensure we're really testing against the jar we just
       built, and not whatever happens to be in builddir. -->

  <!-- This compiles and builds the test jarfile. -->  
  <target name="testjar" depends="jar">
    <fail message="JUnit could not be found in your classpath.  You must download and install it from http://junit.org to build and run the test suite." unless="junit" />
    <mkdir dir="${builddir}/tests"/>
    <javac srcdir="${srcdir}" destdir="${builddir}/tests" debug="${debug}">
      <include name="${package}/test/**" />

      <exclude name="${package}/test/jdbc2/optional/**" unless="jdbc2optionaltests" />
      <exclude name="${package}/test/jdbc3/**" unless="jdbc3tests" />
      <exclude name="${package}/test/util/**" unless="jdbc2optionaltests" />

      <classpath>
        <pathelement location="${jardir}/postgresql.jar"/>
      </classpath>
    </javac>
    <jar jarfile="${jardir}/postgresql-tests.jar" basedir="${builddir}/tests"/>
  </target>
    
  <!-- This actually runs the tests -->
  <target name="runtest" depends="testjar">
    <fail message="Your version of ant doesn't seem to have the junit task available.  I looked for org.apache.tools.ant.taskdefs.optional.junit.JUnitTask, but I couldn't find it." unless="junit.task" />

    <delete file="postgresql-jdbc-tests.debug.txt"/>
    <junit>
      <formatter type="brief" usefile="false"/>

      <sysproperty key="server" value="${server}" />
      <sysproperty key="port" value="${port}" />
      <sysproperty key="database" value="${database}" />
      <sysproperty key="username" value="${username}" />
      <sysproperty key="password" value="${password}" />
      <sysproperty key="preparethreshold" value="${preparethreshold}" />
      <sysproperty key="loglevel" value="${loglevel}" />

      <classpath>
        <pathelement location="${jardir}/postgresql.jar" />
        <pathelement location="${jardir}/postgresql-tests.jar" />
        <pathelement path="${java.class.path}" />
      </classpath>

      <test name="org.postgresql.test.jdbc2.Jdbc2TestSuite" if="junit" />
      <test name="org.postgresql.test.jdbc2.optional.OptionalTestSuite" if="jdbc2optionaltests"/>
      <test name="org.postgresql.test.jdbc3.Jdbc3TestSuite" if="jdbc3tests"/>
      <test name="org.postgresql.test.xa.XATestSuite" if="jdbc3tests"/>
    </junit>
  </target>
  
  <!-- Build and run the tests. -->
  <target name="test" depends="testjar,runtest"/>

  <!-- Build public javadoc -->
  <target name="publicapi" depends="compile">
    <mkdir dir="${builddir}/publicapi" />
    <javadoc destdir="${builddir}/publicapi">
      <classpath>
        <pathelement path="${builddir}" />
        <pathelement path="${java.class.path}" />
      </classpath>
      <fileset dir="${package}">
        <include name="geometric/*.java" />
        <include name="largeobject/*.java" />
        <include name="fastpath/*.java" />
        <include name="PG*.java" />
        <include name="util/PGobject.java" />
	<include name="ssl/WrappedFactory.java" if="ssl" />
	<include name="ssl/NonValidatingFactory.java" if="ssl" />
        <include name="ds/PG*.java" if="datasource" />
	<include name="ds/common/BaseDataSource.java" if="datasource" />
      </fileset>
    </javadoc>
  </target>

  <!-- Build driver-internal javadoc. NB: needs Ant 1.6 & JDK 1.4 for 'breakiterator'. -->
  <target name="privateapi" depends="compile">
    <javadoc destdir="${builddir}/privateapi" breakiterator="yes">
      <classpath>
        <pathelement path="${builddir}" />
        <pathelement path="${java.class.path}" />
      </classpath>
      <fileset dir="${package}">
        <include name="**/*.java"/>
	<exclude name="jdbc2/Jdbc2*.java" unless="jdbc2" />
	<exclude name="jdbc3/Jdbc3*.java" unless="jdbc3" />
	<exclude name="jdbc3g/Jdbc3g*.java" unless="jdbc3g" />
        <exclude name="test/**/*.java"/>
      </fileset>
    </javadoc>
  </target>

  <!-- Build the documentation -->
  <target name="doc" depends="prepare">
   <mkdir dir="${builddir}/doc"/>
   <xslt basedir="doc" destdir="${builddir}/doc" includes="*.xml" force="yes" style="${docbook.stylesheet}">
     <param name="base.dir" expression="${builddir}/doc/"/>
     <param name="use.id.as.filename" expression="1" />
   </xslt>
   <delete file="${builddir}/doc/pgjdbc.html"/>
  </target>

  <!-- Blah. Can't reference an external XML catalog until Ant 1.6.
       So instead we copy the contents of ${docbook.dtd}/catalog.xml
       here, in the form that Ant's xmlcatalog element wants. -->
  <xmlcatalog id="docbook-catalog">  
    <dtd publicId="-//OASIS//DTD DocBook XML V4.2//EN"
      location="${docbook.dtd}/docbookx.dtd"/>
    <entity publicId="-//OASIS//DTD DocBook CALS Table Model V4.2//EN"
      location="${docbook.dtd}/calstblx.dtd"/>
    <entity publicId="-//OASIS//DTD XML Exchange Table Model 19990315//EN"
      location="${docbook.dtd}/soextblx.dtd"/>
    <entity publicId="-//OASIS//ELEMENTS DocBook Information Pool V4.2//EN"
      location="${docbook.dtd}/dbpoolx.mod"/>    
    <entity publicId="-//OASIS//ELEMENTS DocBook Document Hierarchy V4.2//EN"
      location="${docbook.dtd}/dbhierx.mod"/>    
    <entity publicId="-//OASIS//ENTITIES DocBook Additional General Entities V4.2//EN"
      location="${docbook.dtd}/dbgenent.mod"/>    
    <entity publicId="-//OASIS//ENTITIES DocBook Notations V4.2//EN"
      location="${docbook.dtd}/dbnotnx.mod"/>
    <entity publicId="-//OASIS//ENTITIES DocBook Character Entities V4.2//EN"
      location="${docbook.dtd}/dbcentx.mod"/>
  </xmlcatalog>

  <!-- Validate but don't process the documentation.
       This target expects the DocBook XML DTDs, available at
       http://www.docbook.org/xml/4.2/docbook-xml-4.2.zip, to be
       present in ${docbook.dtd}. If they're not present, they will
       be fetched on each validation from www.oasis-open.org.

       Note that if the DTD fetch fails, validation fails with a fairly
       useless error message. Run ant with -verbose to get a more useful
       error. You'll need to set the java properties http.proxyHost and
       http.proxyPort if you need to go via a proxy to fetch the DTDs.
  -->
       
  <target name="validate-doc" depends="prepare">
    <xmlvalidate warn="true">
      <fileset dir="doc" includes="*.xml"/>
      <xmlcatalog refid="docbook-catalog"/>
    </xmlvalidate>
  </target>

</project>
<commit_msg>gij/gcj has some JDK1.5 classes in it, but it only supports JDK1.4 as the default source level.  This confuses older ant versions and our build script tries to compile a JDK1.5 version.  Instead of letting ant detect the java version, let the jvm tell us that itself using java.specification.version as suggested by <NAME>. Also put in a check for a JDK1.6 compile attempt and bail out with an explanatory unsupported error message instead of just failing at some random point.<commit_after><?xml version="1.0"?>
<!--

  Copyright (c) 2004-2005, PostgreSQL Global Development Group

  Build file to allow ant (http://ant.apache.org/) to be used
  to build the PostgreSQL JDBC Driver.

  This file now requires Ant 1.4.1.  2002-04-18

  $PostgreSQL: pgjdbc/build.xml,v 1.66 2005/11/29 07:33:26 jurka Exp $

-->

<!DOCTYPE project [
  <!ENTITY jarfiles "postgresql.jar">
]>

<project name="postgresqlJDBC" default="all" basedir=".">

  <!-- set global properties for this build -->
  <property name="srcdir"  value="." />
  <property name="jardir"  value="jars" />
  <property name="builddir" value="build" />
  <property name="package" value="org/postgresql" />
  <property name="debug" value="on" />

  <!-- default build parameters are in build.properties, these may be
       overridden by local configuration settings in build.local.properties
  -->
  <property file="build.local.properties" />
  <property file="build.properties"/>

  <target name="check_versions">
    <condition property="jdbc2">
      <or>
        <equals arg1="${java.specification.version}" arg2="1.2"/>
        <equals arg1="${java.specification.version}" arg2="1.3"/>
      </or>
    </condition>
    <condition property="jdbc3">
        <equals arg1="${java.specification.version}" arg2="1.4"/>
    </condition>
    <condition property="jdbc3g">
	<equals arg1="${java.specification.version}" arg2="1.5"/>
    </condition>
    <condition property="jdbc3any">
      <or>
        <isset property="jdbc3" />
        <isset property="jdbc3g" />
      </or>
    </condition>
    <condition property="jdbc4">
        <equals arg1="${java.specification.version}" arg2="1.6"/>
    </condition>

    <fail if="jdbc4" message="Building with JDK 1.6 not currently supported." />

    <available property="datasource" classname="javax.sql.DataSource"/>
    <available property="ssl" classname="javax.net.ssl.SSLContext"/>
    <available property="junit" classname="junit.framework.Test"/>
    <available property="junit.task" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

    <condition property="jdbc2optionaltests">
      <and>
        <isset property="datasource"/>
        <isset property="junit"/>
      </and>
    </condition>

    <condition property="jdbc3tests">
      <and>
        <isset property="jdbc3any"/>
        <isset property="datasource"/>
        <isset property="junit"/>
      </and>
    </condition>
  </target>


  <!-- default target -->
  <target name="all">
    <antcall target="jar" />
  </target>


  <!-- create the jar file -->
  <target name="jar" depends="compile">
    <jar jarfile="${jardir}/postgresql.jar">
      <fileset dir="${builddir}">
        <include name="${package}/**/*.class" />
      </fileset>

      <fileset dir="${srcdir}">
        <include name="${package}/translation/*.class" />
      </fileset>
    </jar>
  </target>


  <target name="compile" depends="prepare,check_versions,driver">

    <available classname="org.postgresql.Driver" property="old.driver.present" />
    <fail message="Old driver was detected on classpath or in jre/lib/ext, please remove and try again." if="old.driver.present" />

    <javac classpath="${srcdir}" srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
      <!-- This is the core of the driver.  It is common for all versions. -->
       <include name="${package}/*.java" />
       <include name="${package}/core/**" />
       <include name="${package}/fastpath/**" />
       <include name="${package}/geometric/**" />
       <include name="${package}/largeobject/**" />
       <include name="${package}/util/**" />

       <!--      
       Each jdbcN subpackage is used only if the driver supports *at least* that
       revision of JDBC. That is, a JDBC2 build uses only jdbc2, a JDBC3 build
       uses both jdbc2 and jdbc3, etc.
  
       Within those subpackages, classes beginning with "JdbcN" are assumed to be
       the concrete implementations for JDBC version N and are built only if the
       driver supports *exactly* that version. For example, jdbc2/Jdbc2Statement.java
       is built only if the driver build is a JDBC2 build.
       -->
 
       <!-- jdbc2 subpackage -->
       <include name="${package}/jdbc2/**" if="jdbc2"/>
       <include name="${package}/jdbc2/**" if="jdbc3"/>
       <include name="${package}/jdbc2/**" if="jdbc3g"/>
       <exclude name="${package}/jdbc2/Jdbc2*.java" unless="jdbc2"/>
 
       <!-- jdbc3 subpackage -->
       <include name="${package}/jdbc3/Abstract*.java" if="jdbc3any" />
       <include name="${package}/jdbc3/PSQLSavepoint.java" if="jdcb3any" />
       <include name="${package}/jdbc3/PSQLParameterMetaData.java" if="jdbc3any" />

       
       <include name="${package}/jdbc3/Jdbc3Array.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3Blob.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3CallableStatement.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3Clob.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3Connection.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3DatabaseMetaData.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3PreparedStatement.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3ResultSet.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3ResultSetMetaData.java.java" if="jdbc3"/>
       <include name="${package}/jdbc3/Jdbc3Statement.java" if="jdbc3"/>

       <!-- jdbc3g subpackage -->
       <include name="${package}/jdbc3g/*.java" if="jdbc3g" />
       <exclude name="${package}/jdbc3g/Jdbc3g*.java" unless="jdbc3g" />

       <!-- ssl -->
       <include name="${package}/ssl/*.java" if="ssl" />

       <!-- datasource stuff -->
       <exclude name="${package}/jdbc2/optional/**" unless="datasource"/>
       <include name="${package}/jdbc3/Jdbc3ConnectionPool.java" if="jdbc3any" />
       <include name="${package}/jdbc3/Jdbc3PoolingDataSource.java" if="jdbc3any" />
       <include name="${package}/jdbc3/Jdbc3SimpleDataSource.java" if="jdbc3any" />

       <include name="${package}/ds/**/*.java" if="datasource" />

       <!-- XA stuff -->
       <include name="${package}/xa/*.java" if="jdbc3any" />

    </javac>
  </target>

  <target name="check_driver">
    <uptodate targetfile="${package}/Driver.java" property="driver.uptodate">
      <srcfiles dir=".">
      <include name="${package}/util/PSQLException.java.in"/>
      <include name="${package}/Driver.java.in"/>
      <include name="build.properties"/>
      <include name="build.local.properties" />
      </srcfiles>
    </uptodate>
  </target>

  <!--
    This generates Driver.java from Driver.java.in
    It's required for importing the driver version properties
  -->
  <target name="driver" depends="prepare,check_versions,check_driver"
          unless="driver.uptodate">
    <!-- determine the edition text -->
    <condition property="edition" value="JDBC2 Enterprise">
      <and>
        <available classname="javax.sql.DataSource" />
        <equals arg1="${jdbc2}" arg2="true"/>
      </and>
    </condition>
    <condition property="edition" value="JDBC2">
        <equals arg1="${jdbc2}" arg2="true"/>
    </condition>
    <condition property="edition" value="JDBC3">
        <equals arg1="${jdbc3}" arg2="true"/>
    </condition>
    <condition property="edition" value="JDBC3g">
    	<equals arg1="${jdbc3g}" arg2="true" />
    </condition>

    <!-- determine the connection class -->
    <condition property="connectclass" value="org.postgresql.jdbc2.Jdbc2Connection">
        <equals arg1="${jdbc2}" arg2="true"/>
    </condition>
    <condition property="connectclass" value="org.postgresql.jdbc3.Jdbc3Connection">
        <equals arg1="${jdbc3}" arg2="true"/>
    </condition>
    <condition property="connectclass" value="org.postgresql.jdbc3g.Jdbc3gConnection">
        <equals arg1="${jdbc3g}" arg2="true"/>
    </condition>

    <!-- Determine if we have Throwable.initCause() 
         if so we use it in org.postgresql.util.PSQLException
         instead of appending any nested exception to the message. -->
    <condition property="noInitCause" value="//">
      <equals arg1="${jdbc3any}" arg2="true" />
    </condition>
    
    <condition property="noInitCause" value="">
      <not><equals arg1="${jdbc3any}" arg2="true" /></not>
    </condition>

    <!-- determine the ssl status -->
    <condition property="ssl_config" value="">
        <equals arg1="${ssl}" arg2="true"/>
    </condition>
    <condition property="ssl_config" value="//">
        <not>
            <equals arg1="${ssl}" arg2="true"/>
        </not>
    </condition>
    <condition property="ssl_edition" value="SSL">
        <equals arg1="${ssl}" arg2="true"/>
    </condition>
    <condition property="ssl_edition" value="NO SSL">
        <not>
            <equals arg1="${ssl}" arg2="true"/>
        </not>
    </condition>

    <!-- Some defaults -->
    <filter token="MAJORVERSION" value="${major}" />
    <filter token="MINORVERSION" value="${minor}" />
    <filter token="VERSION" value="PostgreSQL ${fullversion} ${edition} with ${ssl_edition}" />
    <filter token="JDBCCONNECTCLASS" value="${connectclass}" />
    <filter token="DEF_PGPORT" value="${def_pgport}" />
    <filter token="SSL" value="${ssl_config}" />
    <filter token="NOINITCAUSE" value="${noInitCause}" />

     <fail unless="major" message="'major' undefined. Please follow the directions in README."/>
     <fail unless="minor" message="'minor' undefined. Please follow the directions in README."/>
     <fail unless="fullversion" message="'fullversion' undefined. Please follow the directions in README."/>
     <fail unless="def_pgport" message="'def_pgport' undefined. Please follow the directions in README."/>
     <fail unless="enable_debug" message="'enable_debug' undefined. Please follow the directions in README."/>
 
    <!-- Put a check for the current version here -->

    <!-- now copy and filter the file -->
    <copy file="${package}/Driver.java.in"
          overwrite="true"
          tofile="${package}/Driver.java"
          filtering="yes" />
    <copy file="${package}/util/PSQLException.java.in"
          overwrite="true"
          tofile="${package}/util/PSQLException.java"
          filtering="yes" />

    <echo message="Configured build for the ${edition} edition driver with ${ssl_edition}" />
  </target>


  <!-- Prepares the build directory -->
  <target name="prepare">
    <!-- use the enable_debug option from configure -->
    <condition property="debug" value="on">
      <and>
        <equals arg1="${enable_debug}" arg2="yes" />
      </and>
    </condition>
    <mkdir dir="${builddir}" />
    <mkdir dir="${jardir}" />
  </target>


  <!-- This target removes any class files from the build directory -->
  <target name="clean">
    <delete quiet="true" dir="${builddir}" />
    <delete quiet="true" dir="${jardir}" />
    <delete quiet="true" file="${package}/Driver.java" />
    <delete quiet="true" file="${package}/util/PSQLException.java" />
  </target>

  <!-- This compiles and executes the JUnit tests -->

  <!-- defaults for the tests - override these if required -->
  <property name="server" value="localhost" />
  <property name="port" value="${def_pgport}" />
  <property name="database" value="test" />
  <property name="username" value="test" />
  <!-- Password must be <PASSWORD>.  Doesn't matter if trust is used! -->
  <property name="password" value="password" />
  <property name="preparethreshold" value="0" />
  <property name="loglevel" value="0" />

  <!-- The tests now build to a separate directory and jarfile from the
       driver build, to ensure we're really testing against the jar we just
       built, and not whatever happens to be in builddir. -->

  <!-- This compiles and builds the test jarfile. -->  
  <target name="testjar" depends="jar">
    <fail message="JUnit could not be found in your classpath.  You must download and install it from http://junit.org to build and run the test suite." unless="junit" />
    <mkdir dir="${builddir}/tests"/>
    <javac srcdir="${srcdir}" destdir="${builddir}/tests" debug="${debug}">
      <include name="${package}/test/**" />

      <exclude name="${package}/test/jdbc2/optional/**" unless="jdbc2optionaltests" />
      <exclude name="${package}/test/jdbc3/**" unless="jdbc3tests" />
      <exclude name="${package}/test/util/**" unless="jdbc2optionaltests" />

      <classpath>
        <pathelement location="${jardir}/postgresql.jar"/>
      </classpath>
    </javac>
    <jar jarfile="${jardir}/postgresql-tests.jar" basedir="${builddir}/tests"/>
  </target>
    
  <!-- This actually runs the tests -->
  <target name="runtest" depends="testjar">
    <fail message="Your version of ant doesn't seem to have the junit task available.  I looked for org.apache.tools.ant.taskdefs.optional.junit.JUnitTask, but I couldn't find it." unless="junit.task" />

    <delete file="postgresql-jdbc-tests.debug.txt"/>
    <junit>
      <formatter type="brief" usefile="false"/>

      <sysproperty key="server" value="${server}" />
      <sysproperty key="port" value="${port}" />
      <sysproperty key="database" value="${database}" />
      <sysproperty key="username" value="${username}" />
      <sysproperty key="password" value="<PASSWORD>}" />
      <sysproperty key="preparethreshold" value="${preparethreshold}" />
      <sysproperty key="loglevel" value="${loglevel}" />

      <classpath>
        <pathelement location="${jardir}/postgresql.jar" />
        <pathelement location="${jardir}/postgresql-tests.jar" />
        <pathelement path="${java.class.path}" />
      </classpath>

      <test name="org.postgresql.test.jdbc2.Jdbc2TestSuite" if="junit" />
      <test name="org.postgresql.test.jdbc2.optional.OptionalTestSuite" if="jdbc2optionaltests"/>
      <test name="org.postgresql.test.jdbc3.Jdbc3TestSuite" if="jdbc3tests"/>
      <test name="org.postgresql.test.xa.XATestSuite" if="jdbc3tests"/>
    </junit>
  </target>
  
  <!-- Build and run the tests. -->
  <target name="test" depends="testjar,runtest"/>

  <!-- Build public javadoc -->
  <target name="publicapi" depends="compile">
    <mkdir dir="${builddir}/publicapi" />
    <javadoc destdir="${builddir}/publicapi">
      <classpath>
        <pathelement path="${builddir}" />
        <pathelement path="${java.class.path}" />
      </classpath>
      <fileset dir="${package}">
        <include name="geometric/*.java" />
        <include name="largeobject/*.java" />
        <include name="fastpath/*.java" />
        <include name="PG*.java" />
        <include name="util/PGobject.java" />
	<include name="ssl/WrappedFactory.java" if="ssl" />
	<include name="ssl/NonValidatingFactory.java" if="ssl" />
        <include name="ds/PG*.java" if="datasource" />
	<include name="ds/common/BaseDataSource.java" if="datasource" />
      </fileset>
    </javadoc>
  </target>

  <!-- Build driver-internal javadoc. NB: needs Ant 1.6 & JDK 1.4 for 'breakiterator'. -->
  <target name="privateapi" depends="compile">
    <javadoc destdir="${builddir}/privateapi" breakiterator="yes">
      <classpath>
        <pathelement path="${builddir}" />
        <pathelement path="${java.class.path}" />
      </classpath>
      <fileset dir="${package}">
        <include name="**/*.java"/>
	<exclude name="jdbc2/Jdbc2*.java" unless="jdbc2" />
	<exclude name="jdbc3/Jdbc3*.java" unless="jdbc3" />
	<exclude name="jdbc3g/Jdbc3g*.java" unless="jdbc3g" />
        <exclude name="test/**/*.java"/>
      </fileset>
    </javadoc>
  </target>

  <!-- Build the documentation -->
  <target name="doc" depends="prepare">
   <mkdir dir="${builddir}/doc"/>
   <xslt basedir="doc" destdir="${builddir}/doc" includes="*.xml" force="yes" style="${docbook.stylesheet}">
     <param name="base.dir" expression="${builddir}/doc/"/>
     <param name="use.id.as.filename" expression="1" />
   </xslt>
   <delete file="${builddir}/doc/pgjdbc.html"/>
  </target>

  <!-- Blah. Can't reference an external XML catalog until Ant 1.6.
       So instead we copy the contents of ${docbook.dtd}/catalog.xml
       here, in the form that Ant's xmlcatalog element wants. -->
  <xmlcatalog id="docbook-catalog">  
    <dtd publicId="-//OASIS//DTD DocBook XML V4.2//EN"
      location="${docbook.dtd}/docbookx.dtd"/>
    <entity publicId="-//OASIS//DTD DocBook CALS Table Model V4.2//EN"
      location="${docbook.dtd}/calstblx.dtd"/>
    <entity publicId="-//OASIS//DTD XML Exchange Table Model 19990315//EN"
      location="${docbook.dtd}/soextblx.dtd"/>
    <entity publicId="-//OASIS//ELEMENTS DocBook Information Pool V4.2//EN"
      location="${docbook.dtd}/dbpoolx.mod"/>    
    <entity publicId="-//OASIS//ELEMENTS DocBook Document Hierarchy V4.2//EN"
      location="${docbook.dtd}/dbhierx.mod"/>    
    <entity publicId="-//OASIS//ENTITIES DocBook Additional General Entities V4.2//EN"
      location="${docbook.dtd}/dbgenent.mod"/>    
    <entity publicId="-//OASIS//ENTITIES DocBook Notations V4.2//EN"
      location="${docbook.dtd}/dbnotnx.mod"/>
    <entity publicId="-//OASIS//ENTITIES DocBook Character Entities V4.2//EN"
      location="${docbook.dtd}/dbcentx.mod"/>
  </xmlcatalog>

  <!-- Validate but don't process the documentation.
       This target expects the DocBook XML DTDs, available at
       http://www.docbook.org/xml/4.2/docbook-xml-4.2.zip, to be
       present in ${docbook.dtd}. If they're not present, they will
       be fetched on each validation from www.oasis-open.org.

       Note that if the DTD fetch fails, validation fails with a fairly
       useless error message. Run ant with -verbose to get a more useful
       error. You'll need to set the java properties http.proxyHost and
       http.proxyPort if you need to go via a proxy to fetch the DTDs.
  -->
       
  <target name="validate-doc" depends="prepare">
    <xmlvalidate warn="true">
      <fileset dir="doc" includes="*.xml"/>
      <xmlcatalog refid="docbook-catalog"/>
    </xmlvalidate>
  </target>

</project>

{'fraction_non_alphanumeric': 0.17657890397405596, 'fraction_numerical': 0.013576650360028582, 'mean_word_length': 3.198822986383568, 'pattern_counts': {'":': 0, '<': 670, '<?xml version=': 2, '>': 670, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 26}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5464444', 'n_tokens_mistral': 11396, 'n_tokens_neox': 10847, 'n_words': 2598}