build.xml 4.76 KB
Newer Older
1 2 3 4 5
<!--

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

6
  $Id: build.xml,v 1.4 2001/01/18 17:37:11 peter Exp $
7 8 9 10

-->

<project name="postgresqlJDBC" default="jar" basedir=".">
11

12 13
  <!-- set global properties for this build -->
  <property name="src"     value="." />
14
  <property name="jars"    value="jars" />
15 16
  <property name="dest"    value="build" />
  <property name="package" value="org/postgresql" />
17 18
  <property name="major" value="7" />
  <property name="minor" value="1" />
19

20 21 22 23 24
  <!--
    This is a simpler method than utils.CheckVersion
    It defaults to jdbc1, but builds jdbc2 if the java.lang.Byte class is
    in the CLASSPATH (ie JDK1.2 or later), and then enterprise if the
    javax.sql.DataSource class is present.
25

26 27 28 29 30 31
    Important: This must have the following order: jdbc1, jdbc2, enterprise
  -->
  <target name="check_versions">
    <available property="jdk1.2+" classname="java.lang.ThreadLocal" />
    <available property="jdk1.3+" classname="java.lang.StrictMath" />
    <available property="jdk1.2e+" classname="javax.sql.DataSource" />
32
  </target>
33

34 35 36 37 38
  <!--
    This generates Driver.java from Driver.java.in
    It's required for importing the driver version properties
  -->
  <target name="driver" depends="prepare,check_versions">
39

40 41 42 43 44
    <!-- determine the edition text -->
    <property name="edition" value="JDBC1" />
    <available property="edition" value="JDBC2" classname="java.lang.ThreadLocal" />
    <available property="edition" value="JDBC2" classname="java.lang.StrictMath" />
    <available property="edition" value="JDBC2 Enterprise" classname="javax.sql.DataSource" />
45

46 47 48
    <!-- determine the connection class -->
    <property name="connectclass" value="org.postgresql.jdbc1.Connection" />
    <available property="connectclass" value="org.postgresql.jdbc2.Connection" classname="java.lang.ThreadLocal" />
49

50 51 52 53 54
    <!-- Some defaults -->
    <filter token="MAJORVERSION" value="${major}" />
    <filter token="MINORVERSION" value="${minor}" />
    <filter token="VERSION" value="PostgreSQL ${major}.${minor} ${edition}" />
    <filter token="JDBCCONNECTCLASS" value="${connectclass}" />
55

56
    <!-- Put a check for the current version here -->
57

58 59 60 61
    <!-- now copy and filter the file -->
    <copy file="${package}/Driver.java.in"
          tofile="${package}/Driver.java"
          filtering="yes" />
62

63
    <echo message="Configured build for the ${edition} edition driver." />
64

65
  </target>
66

67
  <!-- This target removes any class files from the build directory -->
68 69
  <target name="clean">
    <delete dir="${dest}" />
70
    <delete dir="${jars}" />
71 72
    <delete file="${package}/Driver.java" />
  </target>
73

74 75 76
  <!-- Prepares the build directory -->
  <target name="prepare">
    <mkdir dir="${dest}" />
77
    <mkdir dir="${jars}" />
78
  </target>
79

80
  <!-- This is the core of the driver. It is common for all three versions -->
81
  <target name="compile" depends="prepare,check_versions,driver">
82 83 84 85
    <javac srcdir="${src}" destdir="${dest}">
      <include name="${package}/**" />
      <exclude name="${package}/jdbc1/**" if="jdk1.2+" />
      <exclude name="${package}/jdbc2/**" unless="jdk1.2+" />
86
      <exclude name="${package}/largeobject/PGblob.java" unless="jdk1.2+" />
87 88 89
      <exclude name="${package}/PostgresqlDataSource.java" unless="jdk1.2e+" />
      <exclude name="${package}/xa/**" unless="jdk1.2e+" />
    </javac>
90
    <copy todir="${dest}" overwrite="true" filtering="on">
91 92
      <fileset dir="${src}">
        <include name="**/*.properties" />
93
        <exclude name="${dest}/**" />
94 95 96
      </fileset>
    </copy>
  </target>
97

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
  <!-- This builds the examples -->
  <target name="examples" depends="compile">
    <javac srcdir="${src}" destdir="${dest}">
      <include name="example/**" />
      <exclude name="example/corba/**"/>
    </javac>
  </target>

  <!-- Builds the corba example -->
  <target name="corba" if="jdk1.2+">
    <exec dir="${src}/example/corba" executable="idl2java">
      <arg value="stock.idl" />
    </exec>
    <javac srcdir="${src}" destdir="${dest}">
      <include name="example/corba/**" />
    </javac>
  </target>

116
  <!-- This builds the jar file containing the driver -->
117
  <target name="jar" depends="compile,examples">
118
    <jar jarfile="${jars}/postgresql.jar" basedir="${dest}" includes="org/**" />
119
    <jar jarfile="${jars}/postgresql-examples.jar" basedir="${dest}" includes="example/**" />
120
  </target>
121 122 123 124 125 126 127 128 129 130 131 132 133 134

  <!--
    This installs the jar file. It's called by the build.xml file in the
    root directory of the source (where configure is). Refer to that file
    on how to use it.
  -->
  <target name="install" depends="jar" if="install.directory">
    <copy todir="${install.directory}" overwrite="true" filtering="off">
      <fileset dir="${jars}">
        <include name="**/*.jar" />
      </fileset>
    </copy>
  </target>

135
</project>