aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/build.xml
blob: 114d05813b0ca969ff3cbdd469f921a5804ce5d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?xml version="1.0"?>
<!--

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

  $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.17 2001/07/06 23:07:20 petere Exp $

-->

<!DOCTYPE project [
  <!ENTITY jarfiles "postgresql.jar,postgresql-examples.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" />


  <!--
    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.

    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.2e+" classname="javax.sql.DataSource" />
    <available property="junit" classname="junit.framework.Test" />
  </target>


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


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

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

    <jar jarfile="${jardir}/postgresql-examples.jar" whenempty="fail">
      <fileset dir="${builddir}">
        <include name="example/**/*.class" />
      </fileset>

      <fileset dir="${srcdir}">
        <include name="example/*.properties" />
      </fileset>
    </jar>
  </target>


  <!-- This is the core of the driver.  It is common for all three versions. -->
  <target name="compile" depends="prepare,check_versions,driver">
    <javac srcdir="${srcdir}" destdir="${builddir}">
      <include name="${package}/**" />

      <exclude name="${package}/jdbc1/**" if="jdk1.2+" />
      <exclude name="${package}/jdbc2/**" unless="jdk1.2+" />

      <exclude name="${package}/largeobject/PGblob.java" unless="jdk1.2+" />
      <exclude name="${package}/largeobject/PGclob.java" unless="jdk1.2+" />

      <exclude name="${package}/PostgresqlDataSource.java" unless="jdk1.2e+" />
      <exclude name="${package}/xa/**" unless="jdk1.2e+" />

      <exclude name="${package}/test/**" unless="junit" />
    </javac>
  </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">
    <!-- 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" />

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

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

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

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

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


  <!-- Prepares the build directory -->
  <target name="prepare">
    <mkdir dir="${builddir}" />
    <mkdir dir="${jardir}" />
  </target>


  <!-- This builds the examples -->
  <target name="examples" depends="compile">
    <javac srcdir="${srcdir}" destdir="${builddir}">
      <include name="example/**" />
      <exclude name="example/corba/**"/>
      <exclude name="example/blobtest.java" unless="jdk1.2+"/>
    </javac>
  </target>


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

    <javac srcdir="${srcdir}" destdir="${builddir}">
      <include name="example/corba/**" />
    </javac>
  </target>



  <!-- Install the jar files -->
  <target name="install" depends="all" if="install.directory">
    <copy todir="${install.directory}" overwrite="true">
      <fileset dir="${jardir}" includes="&jarfiles;" />
    </copy>
  </target>


  <!-- Uninstall the jar file -->
  <target name="uninstall" if="install.directory">
    <delete>
      <fileset dir="${install.directory}" includes="&jarfiles;" />
    </delete>
  </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" />
  </target>



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

  <!-- defaults for the tests - override these if required -->
  <property name="database" value="jdbc:postgresql:test" />
  <property name="username" value="test" />
  <!-- Password must be something.  Doesn't matter if trust is used! -->
  <property name="password" value="password" />
  <property name="tablename" value="jdbctest" />
  <!-- junit.ui is one of textui, awtui, or swingui -->
  <property name="junit.ui" value="textui" />


  <target name="test" depends="jar" if="junit">
    <javac srcdir="${srcdir}" destdir="${builddir}">
      <include name="${package}/test/jdbc2/**" if="jdk1.2+" />
      <include name="${package}/test/java2ee/**" if="jdk1.2e+" />
    </javac>

    <java fork="yes" classname="junit.${junit.ui}.TestRunner" taskname="junit" failonerror="true">
      <arg value="org.postgresql.test.JDBC2Tests" />
      <sysproperty key="database" value="${database}" />
      <sysproperty key="username" value="${username}" />
      <sysproperty key="password" value="${password}" />
      <classpath>
        <pathelement location="${builddir}" />
        <pathelement path="${java.class.path}" />
      </classpath>
    </java>
  </target>

</project>