forked from pgjdbc/pgjdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
930 lines (789 loc) · 37.7 KB
/
build.xml
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
<?xml version="1.0"?>
<!--
Copyright (c) 2004-2014, 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
-->
<!DOCTYPE project [
<!ENTITY jarfiles "postgresql.jar">
]>
<project name="postgresqlJDBC" default="all" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<!-- 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"/>
<taskdef uri="antlib:org.apache.maven.artifact.ant"
classpath="lib/maven-ant-tasks-2.1.3.jar"/>
<!-- define artifacts' name, which follows the convention of Maven -->
<property name="maven.jar" value="${jardir}/${maven.artifact.id}-${maven.artifact.version}.jar"/>
<property name="maven.javadoc.jar" value="${jardir}/${maven.artifact.id}-${maven.artifact.version}-javadoc.jar"/>
<property name="maven.sources.jar" value="${jardir}/${maven.artifact.id}-${maven.artifact.version}-sources.jar"/>
<patternset id="jdbc.version.src.pattern">
<!-- This is the core of the driver. It is common for all versions. -->
<include name="${package}/*.java" />
<include name="${package}/core/**" />
<include name="${package}/copy/**" />
<include name="${package}/fastpath/**" />
<include name="${package}/geometric/**" />
<include name="${package}/largeobject/**" />
<include name="${package}/hostchooser/**" />
<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/**"/>
<!-- jdbc3 subpackage -->
<include name="${package}/jdbc3/**"/>
<!-- jdbc3g subpackage -->
<include name="${package}/jdbc3g/**"/>
<!-- jdbc4 subpackage -->
<include name="${package}/jdbc4/Abstract*.java"/>
<exclude name="${package}/jdbc4/Jdbc4*.java" unless="jdbc42"/>
<!-- jdbc42 subpackage -->
<include name="${package}/jdbc42/**" if="jdbc42" />
<!-- ssl -->
<include name="${package}/ssl/**" />
<!-- gss and sspi -->
<include name="${package}/gss/*.java"/>
<include name="${package}/sspi/*.java"/>
<!-- datasource stuff -->
<include name="${package}/ds/**"/>
<!-- XA stuff -->
<include name="${package}/xa/**"/>
<!-- OSGi package -->
<include name="${package}/osgi/*.java"/>
</patternset>
<property name="waffle-jna.version" value="1.7" />
<target name="maven-dependencies" depends="check_versions">
<!--
This is all maven-ant-tasks dependency declaration code.
See http://maven.apache.org/ant-tasks/reference.html
You must depend on either release-version or snapshot-version prior to
this, as it expects properties set by those tasks to be present.
-->
<fail unless="maven.artifact.version.string">snapshot-version or release-version target must run as the first task</fail>
<!-- Expose the Waffle POM so we can reference its version attributes -->
<artifact:dependencies>
<dependency groupId="com.github.dblock.waffle" artifactId="waffle-jna"
version="${waffle-jna.version}" type="pom"/>
<remoteRepository id="${maven.remote.repository.id}"
url="${maven.remote.repository.url}" />
</artifact:dependencies>
<!-- Import Waffle's pom so we can reference its properties -->
<artifact:pom id="waffle-pom"
file="${com.github.dblock.waffle:waffle-jna:pom}"
inheritAllProperties="true"/>
<!--
Declare our own pom with dependencies, which we'll then extract into
filesets with separate artifact:dependencies clauses.
Base it on the template pom in src/pom/pom.xml
-->
<artifact:pom id="org.postgresql:postgresql:pom"
groupId="${maven.group.id}"
artifactId="${maven.artifact.id}"
version="${maven.artifact.version.string}"
name="PostgreSQL JDBC Driver"
description="${maven.artifact.description} ${jdbc.version.upper}"
url="http://jdbc.postgresql.org"
>
<license name="The PostgreSQL License"
url="http://www.postgresql.org/about/licence/"/>
<developer id="davecramer" name="Dave Cramer"/>
<developer id="jurka" name="Kris Jurka"/>
<developer id="oliver" name="Oliver Jowett"/>
<developer id="ringerc" name="Craig Ringer"/>
<scm connection="scm:git:[email protected]:pgjdbc/pgjdbc.git"
url="https://github.com/pgjdbc/pgjdbc" />
<!--
TODO: Is this useful/required? Get pom generator to emit it.
<repository uniqueVersion="false"
id="org.postgresql"
url="https://oss.sonatype.org/content/repositories/snapshots"
layout="legacy"
/>
-->
<!--
Waffle-JNA is used for SSPI authentication support on Windows. We compile
against it on all platforms for consistent builds.
-->
<dependency groupId="com.github.dblock.waffle" artifactId="waffle-jna"
version="${waffle-jna.version}" scope="compile" optional="true">
<!--
We want to force most of Waffle's transitive dependencies to runtime
dependencies so we can't accidentally depend on their contents at
compile time. So exclude them from the compile dependencies, then
declare another runtime dependency on waffle-jna without these
exclusions later.
-->
<exclusion groupId="com.google.guava" artifactId="guava"/>
<exclusion groupId="org.slf4j" artifactId="slf4j-api"/>
<exclusion groupId="org.slf4j" artifactId="slf4j-simple"/>
<!--
Note that we do NOT exclude net.java.dev.jna:jna or
net.java.dev.jna:jna-platform since we intentionally use the one
Waffle exposes.
-->
</dependency>
<!--
Re-declare our waffle-jna dependency without excludes for runtime
bundling use.
-->
<dependency groupId="com.github.dblock.waffle" artifactId="waffle-jna"
version="${waffle-jna.version}" scope="runtime" optional="true"/>
<!-- Ensure JUnit is available, since we hide the ant runtime -->
<dependency groupId="junit" artifactId="junit" version="4.11"
scope="test" optional="true"/>
<dependency groupId="xml-resolver" artifactId="xml-resolver" version="1.2"
scope="compile" optional="true"/>
<dependency groupId="org.osgi" artifactId="org.osgi.core" version="4.3.1"
scope="provided" optional="true"/>
<dependency groupId="org.osgi" artifactId="org.osgi.enterprise" version="4.2.0"
scope="provided" optional="true"/>
</artifact:pom>
<!--
Select a subset of dependencies from our pom as a fileset.
These libraries should be visible to javac:
-->
<artifact:dependencies pathId="dependency.compile.classpath"
filesetId="dependency.compile.fileset"
pomRefId="org.postgresql:postgresql:pom">
<remoteRepository id="${maven.remote.repository.id}"
url="${maven.remote.repository.url}"/>
</artifact:dependencies>
<!-- These libraries should be bundled for use at runtime and added to the
classpath when running tests-->
<artifact:dependencies pathId="dependency.runtime.classpath"
filesetId="dependency.runtime.fileset"
pomRefId="org.postgresql:postgresql:pom">
<remoteRepository id="${maven.remote.repository.id}"
url="${maven.remote.repository.url}"/>
</artifact:dependencies>
<!--
These are used for test compilation and for test running only. They aren't
exposed to javac during the main driver compilation.
-->
<artifact:dependencies pathId="dependency.test.classpath"
filesetId="dependency.test.fileset"
useScope="test"
pomRefId="org.postgresql:postgresql:pom">
<remoteRepository id="${maven.remote.repository.id}"
url="${maven.remote.repository.url}"/>
</artifact:dependencies>
<!--
These are used for building only and are only exposed for ant script
-->
<artifact:dependencies pathId="dependency.build.classpath">
<dependency groupId="biz.aQute.bnd" artifactId="bnd" version="2.4.0"/>
</artifact:dependencies>
<!-- To make life easier for IDE users, copy dependencies to lib/ -->
<copy todir="lib/">
<fileset refid="dependency.compile.fileset"/>
<fileset refid="dependency.runtime.fileset"/>
<fileset refid="dependency.test.fileset"/>
<mapper type="flatten"/>
</copy>
</target>
<target name="check_versions">
<condition property="oldjava">
<or>
<equals arg1="${java.specification.version}" arg2="1.2"/>
<equals arg1="${java.specification.version}" arg2="1.3"/>
<equals arg1="${java.specification.version}" arg2="1.4"/>
<equals arg1="${java.specification.version}" arg2="1.5"/>
</or>
</condition>
<condition property="jdbc4">
<equals arg1="${java.specification.version}" arg2="1.6"/>
</condition>
<condition property="jdbc41">
<equals arg1="${java.specification.version}" arg2="1.7"/>
</condition>
<condition property="jdbc42">
<equals arg1="${java.specification.version}" arg2="1.8"/>
</condition>
<condition property="jdbc4any">
<or>
<isset property="jdbc4" />
<isset property="jdbc41" />
<isset property="jdbc42" />
</or>
</condition>
<condition property="jdbc4_or_jdbc41">
<or>
<isset property="jdbc4" />
<isset property="jdbc41" />
</or>
</condition>
<condition property="jdbc41plus">
<or>
<isset property="jdbc41" />
<isset property="jdbc42" />
</or>
</condition>
<condition property="jdbc42plus">
<isset property="jdbc42" />
</condition>
<condition property="unknownjvm">
<not>
<or>
<isset property="oldjava" />
<isset property="jdbc4any" />
</or>
</not>
</condition>
<fail if="oldjava" message="1.6 or higher JDK is required to build the JDBC driver." />
<fail if="unknownjvm" message="Unknown JDK version." />
<available property="junit.task" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
<condition property="jdbc41tests">
<isset property="jdbc41plus" />
</condition>
<condition property="jdbc42tests">
<isset property="jdbc42plus" />
</condition>
<condition property="jdbc.version" value="jdbc4">
<isset property="jdbc4" />
</condition>
<condition property="jdbc.version" value="jdbc41">
<isset property="jdbc41" />
</condition>
<condition property="jdbc.version" value="jdbc42">
<isset property="jdbc42" />
</condition>
<condition property="jdbc.version.upper" value="JDBC4">
<isset property="jdbc4" />
</condition>
<condition property="jdbc.version.upper" value="JDBC41">
<isset property="jdbc41" />
</condition>
<condition property="jdbc.version.upper" value="JDBC42">
<isset property="jdbc42" />
</condition>
<condition property="jdbc.version.numeric" value="4.0">
<isset property="jdbc4" />
</condition>
<condition property="jdbc.version.numeric" value="4.1">
<isset property="jdbc41" />
</condition>
<condition property="jdbc.version.numeric" value="4.2">
<isset property="jdbc42" />
</condition>
</target>
<!-- default target -->
<target name="all" depends="snapshot-version, jar">
<!-- This task is empty, it just exists to provide dependencies -->
</target>
<!-- create the jar file -->
<target name="jar" depends="compile, artifact-version">
<property name="temp.jar.dir" value="${builddir}/${jardir}"/>
<property name="artifact.jar" value="${jardir}/${artifact.version.string}.jar"/>
<property name="artifact.jar.build" value="${temp.jar.dir}/${artifact.version.string}.jar"/>
<mkdir dir="${temp.jar.dir}" />
<jar jarfile="${artifact.jar.build}">
<fileset dir="${builddir}">
<include name="${package}/**/*.class" />
</fileset>
<fileset dir="${srcdir}">
<include name="${package}/translation/*.class" />
</fileset>
<metainf dir="META-INF">
</metainf>
<manifest>
<attribute name="Main-Class" value="org.postgresql.util.PGJDBCMain"/>
<attribute name="Specification-Title" value="JDBC" />
<attribute name="Specification-Version" value="${jdbc.version.numeric}" />
<attribute name="Specification-Vendor" value="Oracle Corporation" />
<attribute name="Implementation-Title" value="PostgreSQL JDBC Driver" />
<attribute name="Implementation-Version" value="${fullversion}" />
<attribute name="Implementation-Vendor" value="PostgreSQL Global Development Group" />
</manifest>
</jar>
<!-- add OSGi meta information -->
<property name="osgidir" value="${builddir}/osgi"/>
<mkdir dir="${osgidir}"/>
<!-- create a bnd file named after the JAR file so that bnd wrap tool find it -->
<echo file="${osgidir}/${artifact.version.string}.bnd">
Bundle-ManifestVersion: 2
Bundle-Name: PostgreSQL JDBC Driver ${jdbc.version.upper}
Bundle-SymbolicName: org.postgresql.${jdbc.version}
Bundle-Version: ${osgi.version}
Bundle-Vendor: PostgreSQL Global Development Group
Bundle-Copyright: Copyright (c) 2003-2015, PostgreSQL Global Development Group
Bundle-License: http://www.postgresql.org/about/licence/
Bundle-DocURL: http://jdbc.postgresql.org/
Bundle-Classpath: .
Bundle-Activator: org.postgresql.osgi.PGBundleActivator
Require-Capability: osgi.ee;filter:="(&(|(osgi.ee=J2SE)(osgi.ee=JavaSE))(version>=${java.specification.version}))"
Export-Package: org.postgresql*; version=${fullversion}
Import-Package: javax.sql, javax.transaction.xa, javax.naming, *;resolution:=optional
</echo>
<!-- run wrap task from bnd -->
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="dependency.build.classpath"/>
<bndwrap jars="${artifact.jar.build}" output="${artifact.jar}" definitions="${osgidir}"/>
</target>
<!-- create a distribution with docs, dependencies, and driver jar -->
<target name="dist" depends="jar, publicapi">
<zip whenempty="fail" destfile="${artifact.version.string}-dist.zip" level="9">
<!-- Driver JAR -->
<filelist dir="${jardir}">
<file name="${artifact.version.string}.jar"/>
</filelist>
<!-- Create a lib/ directory with dependencies -->
<mappedresources>
<union>
<fileset refid="dependency.compile.fileset"/>
<fileset refid="dependency.runtime.fileset"/>
</union>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.jar" to="lib/*.jar"/>
</chainedmapper>
</mappedresources>
<!-- API javadoc -->
<mappedresources>
<fileset dir="${builddir}">
<include name="publicapi/**"/>
</fileset>
<globmapper from="*" to="doc/*"/>
</mappedresources>
<!-- Manual from doc/pgjdbc.xml -->
<!-- TODO: include generated docbook -->
<filelist>
<file name="doc/pgjdbc.xml"/>
</filelist>
<!-- Misc docs -->
<filelist>
<file name="README.md"/>
<file name="LICENSE"/>
</filelist>
<!--
Processed sources, for IDE debugging use
We don't attempt to make a compileable "dist". Just use git.
-->
<mappedresources>
<fileset dir="${srcdir}">
<patternset refid="jdbc.version.src.pattern"/>
</fileset>
<globmapper from="*" to="src/*"/>
</mappedresources>
</zip>
</target>
<target name="compile" depends="prepare,check_versions,driver,maven-dependencies">
<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}" debuglevel="lines,vars,source" source="${java.specification.version}" includeantruntime="false">
<classpath refid="dependency.compile.classpath"/>
<!-- Do NOT add dependency.test here, we should not depend on junit -->
<!-- Similarly, omit dependency.runtime, we're intentionally not compiling against those libs -->
<patternset refid="jdbc.version.src.pattern"/>
</javac>
</target>
<target name="check_driver">
<uptodate targetfile="${package}/Driver.java" property="driver.uptodate">
<srcfiles dir="${srcdir}">
<include name="${package}/Driver.java.in"/>
<include name="${package}/ds/PGSimpleDataSource.java.in"/>
<include name="${package}/ds/PGPoolingDataSource.java.in"/>
<include name="${package}/ds/PGPooledConnection.java.in"/>
<include name="${package}/ds/PGConnectionPoolDataSource.java.in" />
<include name="${package}/xa/PGXADataSource.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="JDBC4">
<equals arg1="${jdbc4}" arg2="true" />
</condition>
<condition property="edition" value="JDBC4.1">
<equals arg1="${jdbc41}" arg2="true" />
</condition>
<condition property="edition" value="JDBC4.2">
<equals arg1="${jdbc42}" arg2="true" />
</condition>
<!-- determine the connection class -->
<condition property="connectclass" value="org.postgresql.jdbc4.Jdbc4Connection">
<equals arg1="${jdbc4_or_jdbc41}" arg2="true" />
</condition>
<condition property="connectclass" value="org.postgresql.jdbc42.Jdbc42Connection">
<equals arg1="${jdbc42}" arg2="true" />
</condition>
<condition property="notimplementedexception" value="java.sql.SQLFeatureNotSupportedException">
<equals arg1="${jdbc4any}" arg2="true" />
</condition>
<condition property="simpledsclass" value="org.postgresql.ds.jdbc4.AbstractJdbc4SimpleDataSource">
<equals arg1="${jdbc4any}" arg2="true" />
</condition>
<condition property="poolingdsclass" value="org.postgresql.ds.jdbc4.AbstractJdbc4PoolingDataSource">
<equals arg1="${jdbc4any}" arg2="true" />
</condition>
<condition property="pooledconnclass" value="org.postgresql.ds.jdbc4.AbstractJdbc4PooledConnection">
<equals arg1="${jdbc4any}" arg2="true" />
</condition>
<condition property="connpooldsclass" value="org.postgresql.ds.jdbc4.AbstractJdbc4ConnectionPoolDataSource">
<equals arg1="${jdbc4any}" arg2="true" />
</condition>
<condition property="xadsclass" value="org.postgresql.xa.jdbc4.AbstractJdbc4XADataSource">
<equals arg1="${jdbc4any}" arg2="true" />
</condition>
<condition property="makesslclass" value="org.postgresql.ssl.jdbc4.AbstractJdbc4MakeSSL">
<equals arg1="${jdbc4any}" arg2="true" />
</condition>
<!-- 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="NOTIMPLEMENTEDEXCEPTION" value="${notimplementedexception}" />
<filter token="XA_DS_CLASS" value="${xadsclass}" />
<filter token="POOLING_DS_CLASS" value="${poolingdsclass}" />
<filter token="SIMPLE_DS_CLASS" value="${simpledsclass}" />
<filter token="POOLED_CONN_CLASS" value="${pooledconnclass}" />
<filter token="CONN_POOL_DS_CLASS" value="${connpooldsclass}" />
<filter token="DEF_PGPORT" value="${def_pgport}" />
<filter token="MAKE_SSL_CLASS" value="${makesslclass}"/>
<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="${srcdir}/${package}/Driver.java.in"
overwrite="true"
tofile="${srcdir}/${package}/Driver.java"
filtering="yes" />
<copy file="${srcdir}/${package}/ds/PGPoolingDataSource.java.in"
overwrite="true"
tofile="${srcdir}/${package}/ds/PGPoolingDataSource.java"
filtering="yes" />
<copy file="${srcdir}/${package}/ds/PGSimpleDataSource.java.in"
overwrite="true"
tofile="${srcdir}/${package}/ds/PGSimpleDataSource.java"
filtering="yes" />
<copy file="${srcdir}/${package}/ds/PGPooledConnection.java.in"
overwrite="true"
tofile="${srcdir}/${package}/ds/PGPooledConnection.java"
filtering="yes" />
<copy file="${srcdir}/${package}/ds/PGConnectionPoolDataSource.java.in"
overwrite="true"
tofile="${srcdir}/${package}/ds/PGConnectionPoolDataSource.java"
filtering="yes" />
<copy file="${srcdir}/${package}/xa/PGXADataSource.java.in"
overwrite="true"
tofile="${srcdir}/${package}/xa/PGXADataSource.java"
filtering="yes" />
<copy file="${srcdir}/${package}/ssl/MakeSSL.java.in"
overwrite="true"
tofile="${srcdir}/${package}/ssl/MakeSSL.java"
filtering="yes" />
<echo message="Configured build for the ${edition} edition driver." />
</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="${srcdir}/${package}/Driver.java" />
<delete quiet="true" file="${srcdir}/${package}/ds/PGPoolingDataSource.java" />
<delete quiet="true" file="${srcdir}/${package}/ds/PGSimpleDataSource.java" />
<delete quiet="true" file="${srcdir}/${package}/ds/PGPooledConnection.java" />
<delete quiet="true" file="${srcdir}/${package}/ds/PGConnectionPoolDataSource.java" />
<delete quiet="true" file="${srcdir}/${package}/xa/PGXADataSource.java" />
<delete quiet="true" file="${srcdir}/${package}/ssl/MakeSSL.java" />
<delete quiet="true">
<fileset dir="lib">
<include name="*"/>
<exclude name="maven-ant-tasks*.jar"/>
</fileset>
</delete>
</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="test" />
<property name="privilegedUser" value="postgres"/>
<!-- Password must be something. Doesn't matter if trust is used! -->
<property name="privilegedPassword" value=""/>
<property name="preparethreshold" value="5" />
<property name="loglevel" value="0" />
<property name="protocolVersion" value="0" />
<property name="ssltest.properties" value="ssltest.properties" />
<!-- 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="snapshot-version, jar">
<mkdir dir="${builddir}/tests"/>
<javac srcdir="${srcdir}" destdir="${builddir}/tests" debug="${debug}"
debuglevel="lines,vars,source"
source="${java.specification.version}" includeantruntime="false">
<classpath refid="dependency.compile.classpath" />
<classpath refid="dependency.runtime.classpath" />
<classpath refid="dependency.test.classpath" />
<include name="${package}/test/**" />
<exclude name="${package}/test/jdbc4/jdbc41/**" unless="jdbc41tests" />
<exclude name="${package}/test/jdbc42/**" unless="jdbc42tests" />
<classpath>
<pathelement location="${artifact.jar}"/>
</classpath>
</javac>
<copy todir="${builddir}/tests">
<fileset dir="${srcdir}">
<include name="catalog/**/*"/>
</fileset>
</copy>
<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"/>
<property name="testResultsDir" value="${builddir}/testresults" />
<mkdir dir="${testResultsDir}" />
<junit failureproperty="test.fail">
<formatter type="brief" usefile="false"/>
<formatter type="xml" usefile="true" />
<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="privilegedUser" value="${privilegedUser}"/>
<sysproperty key="privilegedPassword" value="${privilegedPassword}"/>
<sysproperty key="preparethreshold" value="${preparethreshold}" />
<sysproperty key="loglevel" value="${loglevel}" />
<sysproperty key="protocolVersion" value="${protocolVersion}" />
<sysproperty key="ssltest.properties" value="${ssltest.properties}" />
<classpath refid="dependency.compile.classpath" />
<classpath refid="dependency.runtime.classpath" />
<classpath refid="dependency.test.classpath" />
<classpath>
<pathelement location="${artifact.jar}" />
<pathelement location="${jardir}/postgresql-tests.jar" />
<pathelement path="${java.class.path}" />
<pathelement path="catalog" />
</classpath>
<test name="org.postgresql.test.jdbc2.Jdbc2TestSuite" outfile="${testResultsDir}/jdbc2"/>
<test name="org.postgresql.test.jdbc2.optional.OptionalTestSuite" outfile="${testResultsDir}/jdbc2optional"/>
<test name="org.postgresql.test.jdbc3.Jdbc3TestSuite" outfile="${testResultsDir}/jdbc3"/>
<test name="org.postgresql.test.xa.XATestSuite" outfile="${testResultsDir}/xa"/>
<test name="org.postgresql.test.extensions.ExtensionsSuite" outfile="${testResultsDir}/extensions"/>
<test name="org.postgresql.test.osgi.OsgiTestSuite" outfile="${testResultsDir}/osgi"/>
<test name="org.postgresql.test.jdbc4.Jdbc4TestSuite" outfile="${testResultsDir}/jdbc4"/>
<test name="org.postgresql.test.jdbc4.jdbc41.Jdbc41TestSuite" if="jdbc41tests" outfile="${testResultsDir}/jdbc41"/>
<test name="org.postgresql.test.jdbc42.Jdbc42TestSuite" if="jdbc42tests" outfile="${testResultsDir}/jdbc42"/>
<test name="org.postgresql.test.hostchooser.MultiHostSuite" outfile="${testResultsDir}/hostchooser"/>
<test name="org.postgresql.test.ssl.SslTestSuite" outfile="${testResultsDir}/ssl"/>
<test name="org.postgresql.test.ssl.SingleCertValidatingFactoryTest" outfile="${testResultsDir}/scsf-ssl"/>
</junit>
<fail if="test.fail" message="Some tests are in failure or error"/>
</target>
<!-- Build and run the tests. -->
<target name="test" depends="snapshot-version,testjar,runtest"/>
<!-- Build public javadoc -->
<target name="publicapi" depends="compile">
<mkdir dir="${builddir}/publicapi" />
<javadoc destdir="${builddir}/publicapi" charset="utf-8">
<classpath>
<pathelement path="${builddir}" />
<pathelement path="${java.class.path}" />
</classpath>
<fileset dir="${srcdir}/${package}">
<include name="copy/*.java" />
<include name="geometric/*.java" />
<include name="largeobject/*.java" />
<include name="fastpath/*.java" />
<include name="PG*.java" />
<include name="util/PGobject.java" />
<include name="util/PGmoney.java" />
<include name="util/PGInterval.java" />
<include name="util/ServerErrorMessage.java" />
<include name="ssl/WrappedFactory.java" />
<include name="ssl/NonValidatingFactory.java" />
<include name="ssl/SingleCertValidatingFactory.java" />
<include name="ds/PG*.java" />
<include name="ds/common/BaseDataSource.java" />
<include name="xa/PGXADataSource.java" />
</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" charset="utf-8">
<classpath>
<pathelement path="${builddir}" />
<pathelement path="${java.class.path}" />
</classpath>
<fileset dir="${srcdir}/${package}">
<include name="**/*.java"/>
<exclude name="jdbc4/*.java" unless="jdbc4any" />
<exclude name="ds/jdbc4/*.java" unless="jdbc4any" />
<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>
</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>
<target name="artifact-version"
description="Sets the version string for the jar artifact"
depends="maven-dependencies">
<property name="artifact.version.string" value="${maven.artifact.id}-${maven.artifact.version}.${jdbc.version}" />
<echo message="Artifact version string: ${artifact.version.string}" />
</target>
<target name="snapshot-version" description="Sets the version string to a snapshot version" depends="check_versions">
<fail if="maven.artifact.version.string">snapshot-version task run but version already set</fail>
<property name="maven.artifact.version.string" value="${maven.artifact.version}-${jdbc.version}-SNAPSHOT" />
<echo message="Maven version string: ${maven.artifact.version.string}" />
</target>
<target name="release-version" description="Sets the version string to a release version" depends="check_versions">
<fail if="maven.artifact.version.string">release-version task run but version already set</fail>
<property name="maven.artifact.version.string" value="${maven.artifact.version}-${jdbc.version}" />
<echo message="Maven version string: ${maven.artifact.version.string}" />
</target>
<target name="prepare-pom" depends="maven-dependencies"
description="Write a pom.xml for uploading to Maven Central">
<mkdir dir="${builddir}/pom"/>
<!-- Write out the pom.xml so we can upload it to Maven Central -->
<artifact:writepom pomRefId="org.postgresql:postgresql:pom"
file="${builddir}/pom/pom.xml" />
</target>
<target name="snapshot" depends="snapshot-version,maven-jar,prepare-pom" description="deploy snapshot version to Maven snapshot repository">
<artifact:mvn>
<artifact:arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file"/>
<artifact:arg value="-Durl=${maven.snapshots.repository.url}"/>
<artifact:arg value="-DrepositoryId=${maven.snapshots.repository.id}"/>
<artifact:arg value="-DpomFile=${builddir}/pom/pom.xml"/>
<artifact:arg value="-Dfile=${maven.jar}"/>
</artifact:mvn>
</target>
<target name="release" depends="release-version,maven-jar,prepare-pom" description="deploy release version to Maven staging repository">
<!-- sign and deploy the main artifact -->
<fail unless="maven.artifact.version.string"/>
<artifact:mvn>
<artifact:arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file" />
<artifact:arg value="-Durl=${maven.staging.repository.url}" />
<artifact:arg value="-DrepositoryId=${maven.staging.repository.id}" />
<artifact:arg value="-DpomFile=${builddir}/pom/pom.xml" />
<artifact:arg value="-Dfile=${maven.jar}" />
<artifact:arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and deploy the sources artifact -->
<artifact:mvn>
<artifact:arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file" />
<artifact:arg value="-Durl=${maven.staging.repository.url}" />
<artifact:arg value="-DrepositoryId=${maven.staging.repository.id}" />
<artifact:arg value="-DpomFile=${builddir}/pom/pom.xml" />
<artifact:arg value="-Dfile=${maven.sources.jar}" />
<artifact:arg value="-Dclassifier=sources" />
<artifact:arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and deploy the javadoc artifact -->
<artifact:mvn>
<artifact:arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file" />
<artifact:arg value="-Durl=${maven.staging.repository.url}" />
<artifact:arg value="-DrepositoryId=${maven.staging.repository.id}" />
<artifact:arg value="-DpomFile=${builddir}/pom/pom.xml" />
<artifact:arg value="-Dfile=${maven.javadoc.jar}" />
<artifact:arg value="-Dclassifier=javadoc" />
<artifact:arg value="-Pgpg" />
</artifact:mvn>
</target>
<!-- create jar files for distribution to maven central -->
<target name="maven-jar" depends="jar, publicapi">
<!-- Copy the built jar into a maven compatible name -->
<copy file="${artifact.jar}" tofile="${maven.jar}"/>
<!-- Create a jar of the javadoc public api -->
<jar jarfile="${maven.javadoc.jar}">
<fileset dir="${builddir}/publicapi">
<include name="**/*"/>
</fileset>
</jar>
<!-- Create a jar of the source code -->
<jar jarfile="${maven.sources.jar}">
<fileset dir="${srcdir}">
<patternset refid="jdbc.version.src.pattern"/>
<include name="META-INF/**/*"/>
</fileset>
</jar>
</target>
</project>