build.xml 88.6 KB
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 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763
<?xml version='1.0'?>
<!--
  Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.

  The MySQL Connector/J is licensed under the terms of the GPLv2
  <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
  There are special exceptions to the terms and conditions of the GPLv2 as it is applied to
  this software, see the FOSS License Exception
  <http://www.mysql.com/about/legal/licensing/foss-exception.html>.

  This program is free software; you can redistribute it and/or modify it under the terms
  of the GNU General Public License as published by the Free Software Foundation; version 2
  of the License.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this
  program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
  Floor, Boston, MA 02110-1301  USA

-->
<project name="MySQL Connector/J" default="dist" basedir=".">
    <description>
Compiling Connector/J
=====================

Connector/J 5.1 supports both JDBC 3 and JDBC 4+ with a single code base. This requires JDBC 3 classes to be compiled with Java 5 and JDBC 4+ to be compiled
with Java 8.
The variables 'com.mysql.jdbc.jdk5' and 'com.mysql.jdbc.jdk8' are used to find the respective compilers when building the driver. Side by side
with these, the variable 'com.mysql.jdbc.extra.libs' must point to the location of third-party libraries that we don't distribute and are required for
compiling.
Compiling all JDBC 4+ code with Java 8 alone produces some warnings since JDBC 4.0 and JDBC 4.1 classes don't require a compliler higher than Java 6. To get
more precise results and avoid warnings use the property 'com.mysql.jdbc.jre6.rtjar' to point to the Java 6 'rt.jar' library (usually in 'jre/lib/rt.jar').
Further details can be found in http://dev.mysql.com/doc/connector-j/en/connector-j-installing-source.html.

Targets: "dist", "full-dist", "package", "full-package", "full-package-no-sources", "compile", "install"


Testing Connector/J
===================

Connector/J 5.1 ships with an extensive test suite that can be run simply by providing a MySQL JDBC URL in the variable 'com.mysql.jdbc.testsuite.url' and by
calling the target "test". If nothing more is set, these tests run with the JVMs referred in the variables 'com.mysql.jdbc.jdk5' and 'com.mysql.jdbc.jdk8' for
JDBC 3 and JDBC 4+ related tests respectively. Alternatively, all tests can be run with a single JVM, provided that it is pointed out in the variable
'com.mysql.jdbc.testsuite.jvm'.
Running the full test suite with different JVMs and different MySQL servers at once is also possible. The variables 'com.mysql.jdbc.testsuite.jvm' and
'com.mysql.jdbc.testsuite.url' can be suffixed with an index ".1" to ".9" to indicate the multiple alternatives which results in the matrix of all possible
combinations. The target "test-multijvm" must be called in this case.
Running only one test set is possible by setting the variable 'test' with the class' fully qualified name. If also a comma separated list of test names is
provided in the variable 'methods', then only these will be executed.

Targets: "test", "test-multijvm"


Compliance
==========

This file ships with targets for these matters. Further details can be found in the respective targets.


Coverage and instrumentation
============================

This file ships with target "test-coverage" for collecting coverage results and "report-coverage" for creating the HTML coverage report.
The JCov library needed to run these targets can be found at http://hg.openjdk.java.net/code-tools/jcov, it's JARs should be placed
into ${com.mysql.jdbc.extra.libs}/jcov directory.
The "test-coverage" target instruments classes using JCov, runs tests collecting coverage info into result file set as
${com.mysql.jdbc.coverage.result.dir}/${com.mysql.jdbc.coverage.result.name}.
The "report-coverage" target first merges coverage result files which full paths are passed via 'com.mysql.jdbc.coverage.merge.files'
property into file which path is passed via 'com.mysql.jdbc.coverage.merge.result' property, then builds the HTML report from
'com.mysql.jdbc.coverage.merge.result' file into the directory passed via 'com.mysql.jdbc.coverage.report.dir' property.
If some properties are not passed to ANT script then default values are used:
    com.mysql.jdbc.coverage.result.dir - "${buildDir}/coverage"
    com.mysql.jdbc.coverage.result.name - "result.xml"
    com.mysql.jdbc.coverage.merge.files - none, merge step is skipped
    com.mysql.jdbc.coverage.merge.result - ${com.mysql.jdbc.coverage.result.dir}/result.xml
    com.mysql.jdbc.coverage.report.dir - ${com.mysql.jdbc.coverage.result.dir}/report

Targets: "test-coverage", "report-coverage"


MySQL Fabric support and testing
================================

Support for MySQL Fabric connections is seamlessly included in Connector/J, so when the driver is compiled it already includes all the required classes for it.
Testing MySQL Fabric support can be done by setting specific variables and running the respective targets. Further details can be found in the last targets in
this file.


Sample 'build.properties' that can be used to compile, build, test and test with multi JVMs
===========================================================================================
~~~start cut here~~~
# Basic settings for 'compile', 'test', 'test-multijvm' and targets that depend on these.

# External libraries needed for both compiling and testing:
# - Further details in http://dev.mysql.com/doc/connector-j/en/connector-j-installing-source.html
# - Mandatory.
com.mysql.jdbc.extra.libs=&lt;full_path_to_connector-j-jardeps&gt;

# JDKs needed for compiling:
# - Must point to JDK home directories.
# - Also used for testing if 'com.mysql.jdbc.testsuite.jvm' is not provided.
# - Mandatory.
com.mysql.jdbc.jdk5=&lt;full_path_to_jdk1.5&gt;
com.mysql.jdbc.jdk8=&lt;full_path_to_jdk1.8&gt;

# Java 6 runtime libraries for compiling JDBC 4.0 and JDBC 4.1 classes:
# - Must point to the library 'jre/lib/rt.jar'.
# - Optional. If not provided, Java 8 runtime is used in its place.
com.mysql.jdbc.jre6.rtjar=&lt;full_path_to_jre1.6/lib/rt.jar&gt;

# Single JVM/MySQL tests:
# - Must point to JDK or JRE home directories.
# - If not provided, JDBC 3 tests are run with 'com.mysql.jdbc.jdk5'.
# - If not provided or pointing to a Java5 JVM, JDBC 4+(&lt;4.2) tests are run with 'com.mysql.jdbc.jdk8'.
# - If not provided or pointing to a JVM lower than 8, JDBC 4.2 tests are run with 'com.mysql.jdbc.jdk8'.
# - Optional.
com.mysql.jdbc.testsuite.jvm=&lt;full_path_to_a_jdk_or_jre&gt;
# - URL to the test database.
# - Any of the current MySQL versions.
# - Mandatory for 'test' target.
com.mysql.jdbc.testsuite.url=jdbc:mysql://&lt;host&gt;:&lt;port&gt;/&lt;testDB&gt;?user=&lt;user&gt;&amp;password=&lt;pwd&gt;

# Multiple JVM/MySQL tests:
# - Must point to JDK or JRE home directories.
# - If pointing to a Java5 JVM, JDBC 4+(&lt;4.2) tests are run with 'com.mysql.jdbc.jdk8' instead.
# - If pointing to a JVM lower than 8, JDBC 4.2 tests are run with 'com.mysql.jdbc.jdk8'.
# - Mandatory (at least one, at most eight) for 'test-multijdk' target.
com.mysql.jdbc.testsuite.jvm.1=&lt;full_path_to_a_jdk_or_jre&gt;
com.mysql.jdbc.testsuite.jvm.2=&lt;full_path_to_a_jdk_or_jre&gt;
com.mysql.jdbc.testsuite.jvm.3=&lt;full_path_to_a_jdk_or_jre&gt;
# - URL to the test database(s).
# - Any of the current MySQL versions.
# - Mandatory (at least one, at most eight) for 'test-multijdk' target.
com.mysql.jdbc.testsuite.url.1=jdbc:mysql://&lt;host1&gt;:&lt;port1&gt;/&lt;testDB1&gt;?user=&lt;user1&gt;&amp;password=&lt;pwd1&gt;
com.mysql.jdbc.testsuite.url.2=jdbc:mysql://&lt;host2&gt;:&lt;port2&gt;/&lt;testDB2&gt;?user=&lt;user2&gt;&amp;password=&lt;pwd2&gt;

# Cancels re-compiling between successive test executions.
# - Implicit in multiple JVM/MySQL in between iterations.
# - Comment variable if not needed.
# - Optional.
com.mysql.jdbc.noCleanBetweenCompiles=yes

# Other targets may require specific settings. Check 'build.xml' for details.
~~~end cut here~~~
    </description>


    <!-- ******************** -->
    <!-- ***** SETTINGS ***** -->
    <!-- ******************** -->


    <!-- If build.properties exists, import it. -->
    <property file="build.properties" />

    <property name="major_version" value="5" />
    <property name="minor_version" value="1" />
    <property name="subminor_version" value="39" />
    <property name="version_status" value="" />

    <property name="version" value="${major_version}.${minor_version}.${subminor_version}${version_status}" />
    <property name="prodName" value="mysql-connector-java" />
    <property name="prodDisplayName" value="MySQL Connector Java" />
    <property name="snapshot.version" value="-SNAPSHOT" />
    <property name="extra.version" value="" />
    <property name="full.version" value="${version}${extra.version}${snapshot.version}" />
    <property name="extra.product.name" value="" />
    <property name="fullProdName" value="${prodName}${extra.product.name}-${full.version}" />
    <property name="sourceDir" value="./src" />
    <property name="buildDir" value="./build" />
    <property name="distDir" value="./dist" />
    <property name="junit.results" value="${buildDir}/junit" />
    <property name="debug.enable" value="on" />
    <property name="toPackage" value="${distDir}/toArchive" />
    <property name="packageDest" value="${toPackage}/${fullProdName}" />

    <!-- Send class files to correct location if running in eclipse. -->
    <condition property="compiler.output" value="bin" else="${buildDir}/${fullProdName}">
        <or>
            <isset property="eclipse.running" />
            <isset property="eclipse.pdebuild.home" />
            <contains string="${ant.home}" substring="plugins" />
        </or>
    </condition>

    <!-- The following properties are needed for finding JDK5 and JDK8 needed for compile and can be passed on the command line to ant via -D switches. -->
    <property name="com.mysql.jdbc.jdk5" value="/usr/lib/jvm/jdk1.5" />
    <property name="com.mysql.jdbc.jdk8" value="/usr/lib/jvm/jdk1.8" />

    <!-- The following property allows to point the location of third-party libraries we don't distribute. Default value points to src/lib so user could either
       put these jars there or pass different location via ant -D switch. -->
    <property name="com.mysql.jdbc.extra.libs" value="${sourceDir}/lib" />

    <!-- The following property is needed for finding a JVM to execute the tests and can be passed on the command line to ant via -D switch. -->
    <property name="com.mysql.jdbc.testsuite.jvm" value="${com.mysql.jdbc.jdk5}" />

    <!-- The following property is needed for building the docs and must be passed on the command line to ant via -D switch. -->
    <property name="com.mysql.jdbc.docs.sourceDir" value="/tmp/connectorj/docs/prebuilt" />

    <!-- The following propertyset is used to forward tests setup configurations as system variables to JUnit tasks. -->
    <propertyset id="junit.system.properties">
        <propertyref prefix="com.mysql.jdbc.test." />
        <!-- Exclude 'testsuite' properties ending with '.url', '.url.N', '.jvm' or '.jvm.N'. -->
        <propertyref regex="^com\.mysql\.jdbc\.testsuite\..*(?&lt;!(?:url|jvm)(?:\.\d)?)$" />
    </propertyset>

    <!-- Java compiler arguments to widen warnings detection and fail on warnings. -->
    <condition property="javac.compilerarg" value="-Xlint:all -Werror" else="">
        <isset property="com.mysql.jdbc.failOnWarnings"/>
    </condition>

    <!-- Classpaths settings. -->
    <path id="built.driver.only.classpath">
        <pathelement location="${buildDir}/${fullProdName}" />
    </path>

    <path id="project.build.classpath">
        <fileset dir="${com.mysql.jdbc.extra.libs}">
            <include name="**/*.jar" />
        </fileset>

        <fileset dir="${buildDir}/${fullProdName}/lib">
            <include name="**/*.jar" />
        </fileset>

        <pathelement location="${buildDir}/${fullProdName}" />
    </path>


    <!-- ************************* -->
    <!-- ***** VERIFICATIONS ***** -->
    <!-- ************************* -->


    <!-- Check for required external libraries. -->
    <target name="-extra-libs-check">
        <fail message="The property 'com.mysql.jdbc.extra.libs' must point to a directory that contains the libraries required for build tasks.">
            <condition>
                <not>
                    <available file="${com.mysql.jdbc.extra.libs}" type="dir" />
                </not>
            </condition>
        </fail>
        <fail message="Hibernate libraries, required for build tasks, must be in the directory '${com.mysql.jdbc.extra.libs}/hibernate4'.">
            <condition>
                <not>
                    <available file="${com.mysql.jdbc.extra.libs}/hibernate4" type="dir" />
                </not>
            </condition>
        </fail>
    </target>


    <!-- Check for required JDKs for compilation. -->
    <target name="-compiler-check" depends="-jdk5-check, -jdk8-check, -jre6-rtjar-check" />


    <!-- Check for required JDK5 for compilation of JDBC 3 implementation. -->
    <target name="-jdk5-check">
        <property name="com.mysql.jdbc.jdk5.java" value="${com.mysql.jdbc.jdk5}/bin/java" />
        <property name="com.mysql.jdbc.jdk5.javac" value="${com.mysql.jdbc.jdk5}/bin/javac" />

        <local name="com.mysql.jdbc.jdk5.version" />
        <exec executable="${com.mysql.jdbc.jdk5.java}"
              outputproperty="com.mysql.jdbc.jdk5.version"
              failonerror="false"
              failifexecutionfails="false"
              resultproperty="jdk5checkexitstatus">
            <arg value="-version" />
        </exec>

        <fail message="Java 5 is required. Set the full path to this JDK home with the property 'com.mysql.jdbc.jdk5'. Default: '/usr/lib/jvm/jdk1.5').
Java 8 (for JDBC 4+ implementation) is also required. Set the full path to this JDK home with the property 'com.mysql.jdbc.jdk8'. Default: '/usr/lib/jvm/jdk1.8'.">
            <condition>
                <not>
                    <and>
                        <equals arg1="${jdk5checkexitstatus}" arg2="0" />
                        <contains string="${com.mysql.jdbc.jdk5.version}" substring="java version &quot;1.5" casesensitive="true" />
                    </and>
                </not>
            </condition>
        </fail>
    </target>


    <!-- Check for required JDK8 for compilation of JDBC 4+ implementation. -->
    <target name="-jdk8-check">
        <property name="com.mysql.jdbc.jdk8.java" value="${com.mysql.jdbc.jdk8}/bin/java" />
        <property name="com.mysql.jdbc.jdk8.javac" value="${com.mysql.jdbc.jdk8}/bin/javac" />

        <local name="com.mysql.jdbc.jdk8.version" />
        <exec executable="${com.mysql.jdbc.jdk8.java}"
              outputproperty="com.mysql.jdbc.jdk8.version"
              failonerror="false"
              failifexecutionfails="false"
              resultproperty="jdk8checkexitstatus">
            <arg value="-version" />
        </exec>

        <fail message="Java 8 (for JDBC 4+ implementation) is required. Set the full path to this JDK home with the property 'com.mysql.jdbc.jdk8'. Default: '/usr/lib/jvm/jdk1.8'.">
            <condition>
                <not>
                    <and>
                        <equals arg1="${jdk8checkexitstatus}" arg2="0" />
                        <contains string="${com.mysql.jdbc.jdk8.version}" substring="java version &quot;1.8" casesensitive="true" />
                    </and>
                </not>
            </condition>
        </fail>
    </target>


    <!-- Check for Java 6 runtime libraries for compilation of JDBC 4.0 and JDBC 4.1 implementations. Ignored if property is undefined. -->
    <target name="-jre6-rtjar-check">
        <fail message="Invalid or missing Java 6 runtime library pointed by 'com.mysql.jdbc.jre6.rtjar'. ">
            <condition>
                <and>
                    <isset property="com.mysql.jdbc.jre6.rtjar" />
                    <not>
                        <available file="${com.mysql.jdbc.jre6.rtjar}" />
                    </not>
                </and>
            </condition>
        </fail>
    </target>


    <!-- Check provided URL for running unit tests. -->
    <target name="-testsuite-url-check">
        <condition property="com.mysql.jdbc.testsuite.url.final" value="${com.mysql.jdbc.testsuite.url.internal}" else="${com.mysql.jdbc.testsuite.url}">
            <isset property="com.mysql.jdbc.testsuite.url.internal" />
        </condition>

        <fail message="Set the MySQL database connection string for the test suite in one of the properties, 'com.mysql.jdbc.testsuite.url' or 'com.mysql.jdbc.testsuite.url.N', according to desired target.">
            <condition>
                <not>
                    <or>
                        <isset property="com.mysql.jdbc.testsuite.url.internal" />
                        <isset property="com.mysql.jdbc.testsuite.url" />
                    </or>
                </not>
            </condition>
        </fail>
    </target>


    <!-- Check provided URL for running compliance tests. -->
    <target name="-compliance-url-check">
        <condition property="com.mysql.jdbc.compliance.url.final" value="${com.mysql.jdbc.compliance.url.internal}" else="${com.mysql.jdbc.compliance.url}">
            <isset property="com.mysql.jdbc.compliance.url.internal" />
        </condition>

        <fail message="Set the MySQL database connection string for the compliance tests in one of the properties, 'com.mysql.jdbc.compliance.url' or 'com.mysql.jdbc.compliance.url.N', according to desired target.">
            <condition>
                <not>
                    <or>
                        <isset property="com.mysql.jdbc.compliance.url.internal" />
                        <isset property="com.mysql.jdbc.compliance.url" />
                    </or>
                </not>
            </condition>
        </fail>
    </target>


    <!-- Check provided JVM for running tests. -->
    <target name="-testsuite-jvm-check" depends="-jdk8-check">
        <condition property="com.mysql.jdbc3.testsuite.jvm.java"
                   value="${com.mysql.jdbc.testsuite.jvm.internal}/bin/java"
                   else="${com.mysql.jdbc.testsuite.jvm}/bin/java">
            <isset property="com.mysql.jdbc.testsuite.jvm.internal" />
        </condition>

        <local name="com.mysql.jdbc.testsuite.jvm.version" />
        <exec executable="${com.mysql.jdbc3.testsuite.jvm.java}"
              outputproperty="com.mysql.jdbc.testsuite.jvm.version"
              failonerror="false"
              failifexecutionfails="false"
              resultproperty="jvmcheckexitstatus">
            <arg value="-version" />
        </exec>

        <fail message="Testing Connector/J requires a JVM 1.5 or higher. Set the path to this JVM (JRE or JDK) home with the property 'com.mysql.jdbc.testsuite.jvm'. Default: '${com.mysql.jdbc.jdk5}'.">
            <condition>
                <not>
                    <equals arg1="${jvmcheckexitstatus}" arg2="0" />
                </not>
            </condition>
        </fail>

        <!-- Run JDBC 4+(<4.2) tests with ${com.mysql.jdbc.jdk8.java} if chosen JVM for tests is JVM5 -->
        <condition property="com.mysql.jdbc4.testsuite.jvm.java" value="${com.mysql.jdbc.jdk8.java}" else="${com.mysql.jdbc3.testsuite.jvm.java}">
            <contains string="${com.mysql.jdbc.testsuite.jvm.version}" substring="java version &quot;1.5" casesensitive="true" />
        </condition>

        <!-- Run JDBC 4.2 tests with ${com.mysql.jdbc.jdk8.java} if chosen JVM for tests is JVM5 or JVM6 or JVM7 -->
        <condition property="com.mysql.jdbc42.testsuite.jvm.java" value="${com.mysql.jdbc.jdk8.java}" else="${com.mysql.jdbc3.testsuite.jvm.java}">
            <or>
                <contains string="${com.mysql.jdbc.testsuite.jvm.version}" substring="java version &quot;1.5" casesensitive="true" />
                <contains string="${com.mysql.jdbc.testsuite.jvm.version}" substring="java version &quot;1.6" casesensitive="true" />
                <contains string="${com.mysql.jdbc.testsuite.jvm.version}" substring="java version &quot;1.7" casesensitive="true" />
            </or>
        </condition>
    </target>


    <!-- ************************************** -->
    <!-- ***** INITIALIZATION & FILE COPY ***** -->
    <!-- ************************************** -->


    <!-- Prepares files and settings for compiling driver. -->
    <target name="init" depends="-compiler-check, -init-copy, -init-filter-license, -init-no-crypto">
        <!-- The following is needed for source distributions as the classpath can't be dynamically altered, and not having this directory present causes the
             build to fail. -->
        <available file="${com.mysql.jdbc.docs.sourceDir}" property="com.mysql.jdbc.docs.sourcesPresent" />
        <available classname="com.mchange.v2.c3p0.QueryConnectionTester" classpathref="project.build.classpath" property="com.mysql.jdbc.c3p0Present" />
        <available classname="org.apache.log4j.Logger" classpathref="project.build.classpath" property="com.mysql.jdbc.log4jPresent" />
        <available classname="org.jboss.resource.adapter.jdbc.ValidConnectionChecker"
                   classpathref="project.build.classpath"
                   property="com.mysql.jdbc.jbossPresent" />
    </target>


    <!-- Copy source files and fix licensing header in source files. -->
    <target name="-init-copy" depends="-init-copy-common, -replace-headers-commercial" />


    <!-- Copy source files. -->
    <target name="-init-copy-common" depends="clean">
        <tstamp />

        <mkdir dir="${buildDir}" />

        <exec dir="."
              executable="cmd"
              osfamily="windows"
              outputproperty="git_revision_from_cmd"
              failonerror="false"
              failifexecutionfails="false"
              resultproperty="gitcheckexitstatus">
            <arg line="/c git rev-parse --verify HEAD^^{commit}" />
        </exec>

        <exec executable="git"
              osfamily="unix"
              outputproperty="git_revision_from_cmd"
              failonerror="false"
              failifexecutionfails="false"
              resultproperty="gitcheckexitstatus">
            <arg line="rev-parse --verify HEAD^{commit}" />
        </exec>

        <!-- The following workaround is needed for the RE builds environment, which build from a non-versioned directory, so revision information is provided
            from an external revision-info.properties file. -->
        <property prefix="revinfo" file="revision-info.properties" />

        <condition property="git_revision" value="${git_revision_from_cmd}" else="${revinfo.commit}">
            <equals arg1="${gitcheckexitstatus}" arg2="0" />
        </condition>

        <filterset id="versionFilterset">
            <filter token="MYSQL_CJ_MAJOR_VERSION" value="${major_version}" />
            <filter token="MYSQL_CJ_MINOR_VERSION" value="${minor_version}" />
            <filter token="MYSQL_CJ_SUBMINOR_VERSION" value="${subminor_version}" />
            <filter token="MYSQL_CJ_VERSION_STATUS" value="${version_status}" />
            <filter token="MYSQL_CJ_VERSION" value="${full.version}" />
            <filter token="MYSQL_CJ_REVISION" value="${git_revision}" />
            <filter token="MYSQL_CJ_FULL_PROD_NAME" value="${fullProdName}" />
            <filter token="MYSQL_CJ_DISPLAY_PROD_NAME" value="${prodDisplayName}" />
        </filterset>

        <condition property="licensetype" value="commercial" else="GPL">
            <isset property="com.mysql.jdbc.commercialBuild" />
        </condition>
        <filterset id="licenseFilterset">
            <filter token="MYSQL_CJ_LICENSE_TYPE" value="${licensetype}" />
        </filterset>

        <copy todir="${buildDir}/${fullProdName}" filtering="true">
            <fileset dir="${sourceDir}/" excludes="**/CVS">
                <patternset id="classjar">
                    <exclude name="**/*.class*" />
                    <exclude name="**/*.jar" />
                </patternset>
            </fileset>

            <filterset refid="versionFilterset" />
            <filterset refid="licenseFilterset" />
        </copy>

        <copy todir="${buildDir}/${fullProdName}" filtering="false">
            <fileset dir="${sourceDir}" excludes="**/CVS">
                <patternset id="dojar">
                    <include name="**/*.jar*" />
                </patternset>
            </fileset>
        </copy>
    </target>


    <!-- Fix licensing header in source files. -->
    <target name="-replace-headers-commercial" if="com.mysql.jdbc.commercialBuild">
        <replaceregexp match=" *The MySQL Connector.*1301  ?USA"
                       replace="${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}"
                       flags="s">
            <fileset dir="${buildDir}/${fullProdName}" includes="**/*" />
        </replaceregexp>
    </target>


    <!-- Add commercial license configuration class (Build). -->
    <target name="-init-filter-license" depends="-extra-libs-check, -init-copy" if="com.mysql.jdbc.filterLicense">
        <copy file="${com.mysql.jdbc.extra.libs}/CommercialLicenseConfiguration.notjava"
              toFile="${buildDir}/${fullProdName}/com/mysql/jdbc/LicenseConfiguration.java"
              overwrite="true" />
    </target>


    <!-- Add no-crypto export control class (Build). -->
    <target name="-init-no-crypto" depends="-extra-libs-check, -init-copy" if="com.mysql.jdbc.noCryptoBuild">
        <copy file="${com.mysql.jdbc.extra.libs}/ExportControlledNoCrypto.notjava"
              toFile="${buildDir}/${fullProdName}/com/mysql/jdbc/ExportControlled.java"
              overwrite="true" />
    </target>


    <!-- Copy commercial license configuration class (Package). -->
    <target name="-copy-filter-license" depends="-extra-libs-check, -init-copy" if="com.mysql.jdbc.filterLicense">
        <copy file="${com.mysql.jdbc.extra.libs}/CommercialLicenseConfiguration.notjava"
              toFile="${packageDest}/src/com/mysql/jdbc/LicenseConfiguration.java"
              overwrite="true" />
    </target>


    <!-- Copy no-crypto export control class (Package). -->
    <target name="-copy-no-crypto" depends="-extra-libs-check, -init-copy" if="com.mysql.jdbc.noCryptoBuild">
        <copy file="${com.mysql.jdbc.extra.libs}/ExportControlledNoCrypto.notjava"
              toFile="${packageDest}/src/com/mysql/jdbc/ExportControlled.java"
              overwrite="true" />
    </target>


    <!-- Copy README-commercial info (Package). -->
    <target name="-copy-readme-commercial" depends="-extra-libs-check, -init-copy" if="com.mysql.jdbc.commercialBuild">
        <copy file="${com.mysql.jdbc.extra.libs}/README-commercial" tofile="${packageDest}/README.txt" filtering="true">
            <filterset refid="versionFilterset" />
            <filterset refid="licenseFilterset" />
        </copy>
        <copy file="${packageDest}/README.txt" tofile="${packageDest}/README" overwrite="true" />
    </target>


    <!-- Copy README info (Package). -->
    <target name="-copy-readme-noncommercial" depends="-init-copy" unless="com.mysql.jdbc.commercialBuild">
        <copy file="${basedir}/README" tofile="${packageDest}/README.txt" filtering="true">
            <filterset refid="versionFilterset" />
        </copy>
        <copy file="${packageDest}/README.txt" tofile="${packageDest}/README" overwrite="true" />
    </target>


    <!-- Copy LICENCE.mysql and replace license commercial headers (Package). -->
    <target name="-replace-license-commercial" depends="-extra-libs-check, -init-copy" if="com.mysql.jdbc.commercialBuild">
        <delete file="${packageDest}/COPYING" />
        <copy file="${com.mysql.jdbc.extra.libs}/LICENSE.mysql" toDir="${packageDest}" />

        <!-- For safety. -->
        <replaceregexp match=" *The MySQL Connector.*1301  ?USA"
                       replace="${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}${line.separator}"
                       flags="s">
            <fileset dir="${packageDest}" includes="**/*" />
        </replaceregexp>
    </target>


    <!-- ************************************ -->
    <!-- ***** DISTRIBUTION & PACKAGING ***** -->
    <!-- ************************************ -->


    <!-- Make MySQL GPL-licensed or commercially-licensed binaries package, that contain sources and docs. -->
    <target name="full-package"
            description="Builds driver, binary .jar file, docs and packages (.zip, .tar.gz) suitable for distribution that _do_ contain sources and docs."
            depends="full-dist, -make-packages, -create-archives" />


    <!-- Make MySQL GPL-licensed or commercially-licensed binaries package, that doesn't contain sources but contain docs. -->
    <target name="full-package-no-sources"
            description="Builds driver, binary .jar file, docs and packages (.zip, .tar.gz) suitable for distribution that do _not_ contain sources but contain docs."
            depends="full-dist, -make-packages, -remove-sources, -create-archives" />


    <!-- Make MySQL GPL-licensed or commercially-licensed binaries package, that contain sources but no docs. -->
    <target name="package"
            description="Builds driver, binary .jar file, docs and packages (.zip, .tar.gz) suitable for distribution that _do_ contain sources but no docs."
            depends="dist, -make-packages, -create-archives" />


    <!-- Build a distribution 'image' that include docs. -->
    <target name="full-dist" description="Builds driver, binary .jar file and docs, basically a distribution 'image'." depends="dist, -bundle-docs" />


    <!-- Build and install the driver jar into the local maven repository. -->
    <target name="install" description="Builds and installs the driver jar into the local maven repository." depends="full-package">
        <exec executable="mvn" osfamily="unix" failonerror="true" failifexecutionfails="true">
            <arg line="install:install-file 
                -Dfile=${mavenUploadDir}/${fullProdName}.jar
                -Dsources=${mavenUploadDir}/${fullProdName}-sources.jar
                -DpomFile=${buildDir}/${fullProdName}/doc/sources/pom.xml
                -DcreateChecksum=true" />
        </exec>
    </target>


    <!-- Build a distribution 'image' that doesn't include docs. -->
    <target name="dist" description="Builds driver and binary .jar file, basically a distribution 'image' without docs." depends="init, compile">
        <delete file="${buildDir}/${fullProdName}-bin.jar" />

        <mkdir dir="${buildDir}/META-INF" />

        <!-- JDBC 4+ support of service provider mechanism. -->
        <mkdir dir="${buildDir}/${fullProdName}/META-INF/services/" />
        <echo file="${buildDir}/${fullProdName}/META-INF/services/java.sql.Driver"
              message="com.mysql.jdbc.Driver${line.separator}com.mysql.fabric.jdbc.FabricMySQLDriver" />

        <property name="osgid-version" value="${major_version}.${minor_version}.${subminor_version}" />

        <property name="jee-imports"
                  value="javax.naming,javax.naming.spi,javax.sql,javax.transaction.xa;version=&quot;[1.0.1, 2.0.0)&quot;;resolution:=optional" />
        <property name="crypto-imports" value="javax.net,javax.net.ssl;version=&quot;[1.0.1, 2.0.0)&quot;;resolution:=optional" />
        <property name="jdbc4-imports"
                  value="javax.xml.parsers, javax.xml.stream,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,org.w3c.dom,org.xml.sax,org.xml.sax.helpers;resolution:=optional" />
        <property name="integration-imports"
                  value="com.mchange.v2.c3p0;version=&quot;[0.9.1.2, 1.0.0)&quot;;resolution:=optional,org.jboss.resource.adapter.jdbc;resolution:=optional,org.jboss.resource.adapter.jdbc.vendor;resolution:=optional" />

        <property name="driver-exports"
                  value="com.mysql.jdbc;version=&quot;${osgid-version}&quot;;uses:=&quot;com.mysql.jdbc.log,javax.naming,javax.net.ssl,javax.xml.transform,org.xml.sax&quot;" />
        <property name="jee-exports"
                  value="com.mysql.jdbc.jdbc2.optional;version=&quot;${osgid-version}&quot;;uses:=&quot;com.mysql.jdbc,com.mysql.jdbc.log,javax.naming,javax.sql,javax.transaction.xa&quot;" />
        <property name="logging-exports" value="com.mysql.jdbc.log;version=&quot;${osgid-version}&quot;" />
        <property name="profiling-exports" value="com.mysql.jdbc.profiler;version=&quot;${osgid-version}&quot;;uses:=&quot;com.mysql.jdbc&quot;" />
        <property name="util-exports" value="com.mysql.jdbc.util;version=&quot;${osgid-version}&quot;;uses:=&quot;com.mysql.jdbc.log&quot;" />
        <property name="exceptions-exports" value="com.mysql.jdbc.exceptions;version=&quot;${osgid-version}&quot;" />
        <property name="jdbc4-exceptions-exports"
                  value="com.mysql.jdbc.exceptions.jdbc4;version=&quot;${osgid-version}&quot;;uses:=&quot;com.mysql.jdbc&quot;" />
        <property name="fabric-exports"
                  value="com.mysql.fabric.jdbc;version=&quot;${osgid-version}&quot;;uses:=&quot;com.mysql.jdbc&quot;" />

        <property name="interceptors-exports" value="com.mysql.jdbc.interceptors;version=&quot;${osgid-version}&quot;;uses:=&quot;com.mysql.jdbc&quot;" />
        <property name="integration-exports"
                  value="com.mysql.jdbc.integration.c3p0;version=&quot;${osgid-version}&quot;,com.mysql.jdbc.integration.jboss;version=&quot;${osgid-version}&quot;" />
        <property name="configs-exports" value="com.mysql.jdbc.configs;version=&quot;${osgid-version}&quot;" />
        <property name="legacy-exports" value="org.gjt.mm.mysql;version=&quot;${osgid-version}&quot;" />

        <manifest file="${buildDir}/${fullProdName}/META-INF/MANIFEST.MF">
            <attribute name="Built-By" value="${user.name}" />
            <attribute name="Specification-Title" value="JDBC" />
            <attribute name="Specification-Version" value="4.2" />
            <attribute name="Specification-Vendor" value="Oracle Corporation" />
            <attribute name="Implementation-Title" value="${prodDisplayName}" />
            <attribute name="Implementation-Version" value="${full.version}" />
            <attribute name="Implementation-Vendor-Id" value="com.mysql" />
            <attribute name="Implementation-Vendor" value="Oracle" />

            <!-- OSGi -->
            <attribute name="Bundle-Vendor" value="Oracle Corporation" />
            <attribute name="Bundle-Classpath" value="." />
            <attribute name="Bundle-Version" value="${osgid-version}" />
            <attribute name="Bundle-Name" value="Oracle Corporation's JDBC Driver for MySQL" />
            <attribute name="Bundle-ManifestVersion" value="2" />
            <attribute name="Bundle-SymbolicName" value="com.mysql.jdbc" />
            <attribute name="Export-Package"
                       value="${driver-exports},${jee-exports},${logging-exports},${profiling-exports},${util-exports},${exceptions-exports},${jdbc4-exceptions-exports},${interceptors-exports},${integration-exports},${configs-exports},${legacy-exports},${fabric-exports}" />
            <attribute name="Import-Package" value="${crypto-imports},${jdbc4-imports},${jee-imports},${integration-imports}" />
        </manifest>

        <jar jarfile="${buildDir}/${fullProdName}/${fullProdName}-bin.jar"
             basedir="${compiler.output}"
             includes="**/*.class,**/*.properties*,META-INF/**"
             excludes="testsuite/**,demo/**"
             index="true"
             manifest="${buildDir}/${fullProdName}/META-INF/MANIFEST.MF" />
    </target>


    <!-- Prepare a package for archiving. -->
    <target name="-make-packages"
            depends="-make-packages-init, -copy-filter-license, -copy-no-crypto, -copy-readme-commercial, -copy-readme-noncommercial, -replace-license-commercial">
        <!-- Fix CRLF for various platforms. -->

        <!-- For Windows-y platforms. -->
        <fixcrlf srcdir="${packageDest}" tab="remove" tablength="8" eol="crlf" includes="**/README.txt" />

        <!-- For Unix-y platforms. -->
        <fixcrlf srcdir="${packageDest}" tab="remove" tablength="8" eol="lf" includes="**/README" />
    </target>


    <!-- Prepare a package for archiving (initialize). -->
    <target name="-make-packages-init" depends="dist">
        <mkdir dir="${distDir}" />
        <mkdir dir="${toPackage}" />
        <mkdir dir="${packageDest}" />

        <delete dir="${toPackage}" />

        <patternset id="non.test.sources">
            <exclude name="**/*.nb*" />
            <exclude name="**/*.bak" />
            <exclude name="**/*.*~" />
            <exclude name="**/clover/*" />
            <exclude name="**/checkstyle/*" />
            <exclude name="**/.*" />
        </patternset>

        <copy todir="${packageDest}">
            <fileset dir="${buildDir}/${fullProdName}" includes="debug/*, docs/**, *.jar" excludes="docs/sources">
                <patternset refid="non.test.sources" />
            </fileset>

            <fileset dir="." includes="src/com/**, src/doc/**, src/lib/*, src/org/**, src/testsuite/**, src/demo/**, build.xml, CHANGES, COPYING">
                <patternset refid="non.test.sources" />
            </fileset>
        </copy>
    </target>


    <!-- Delete source files from package. -->
    <target name="-remove-sources">
        <echo>Removing sources from '${toPackage}'</echo>
        <delete>
            <fileset dir="${packageDest}">
                <include name="**/*.java" />
                <include name="build.xml" />
            </fileset>
        </delete>

        <delete dir="${packageDest}/src" />

        <property name="com.mysql.jdbc.noSources" value="yes" />
    </target>


    <!-- Create archive files with package. -->
    <target name="-create-archives" depends="-create-common-archives, -create-maven-archive" />


    <!-- Create common archives. -->
    <target name="-create-common-archives" depends="-make-packages">
        <delete file="${distDir}/${fullProdName}.tar.gz" />

        <tar destfile="${distDir}/${fullProdName}.tar.gz" compression="gzip" longfile="gnu">
            <tarfileset dir="${toPackage}">
                <patternset refid="non.test.sources" />
            </tarfileset>
        </tar>
        <checksum file="${distDir}/${fullProdName}.tar.gz" forceOverwrite="yes" fileext=".md5" algorithm="MD5" />

        <delete file="${distDir}/${fullProdName}.zip" />

        <zip destfile="${distDir}/${fullProdName}.zip">
            <fileset dir="${toPackage}">
                <patternset refid="non.test.sources" />
            </fileset>
        </zip>
        <checksum file="${distDir}/${fullProdName}.zip" forceOverwrite="yes" fileext=".md5" algorithm="MD5" />
    </target>


    <!-- Create a Maven bundle for upload to their repository. -->
    <target name="-create-maven-archive"
            depends="-make-packages, -create-maven-archive-common, -create-maven-archive-sources"
            unless="com.mysql.jdbc.commercialBuild">
        <delete file="${distDir}/${fullProdName}.maven.tar.gz" />

        <tar destfile="${distDir}/${fullProdName}.maven.tar.gz" basedir="${mavenUploadDir}" compression="gzip" longfile="gnu" />
    </target>


    <!-- Create a Maven bundle for upload to their repository (common files to all packaging modes). -->
    <target name="-create-maven-archive-common">
        <tempfile destdir="${buildDir}" prefix="maven-bundle-" property="mavenUploadDir" />

        <mkdir dir="${mavenUploadDir}" />

        <jar jarfile="${mavenUploadDir}/${fullProdName}.jar"
             basedir="${compiler.output}"
             includes="**/*.class,**/*.properties*,COPYING,README,META-INF/**"
             excludes="testsuite/**,demo/**"
             index="true"
             manifest="${buildDir}/${fullProdName}/META-INF/MANIFEST.MF" />
        <checksum file="${mavenUploadDir}/${fullProdName}.jar" forceOverwrite="yes" fileext=".md5" algorithm="MD5" />
        <checksum file="${mavenUploadDir}/${fullProdName}.jar" forceOverwrite="yes" fileext=".sha1" algorithm="SHA-1" />

        <copy file="${buildDir}/${fullProdName}/doc/sources/pom.xml" toFile="${mavenUploadDir}/${fullProdName}.pom" filtering="true" />
        <checksum file="${mavenUploadDir}/${fullProdName}.pom" forceOverwrite="yes" fileext=".md5" algorithm="MD5" />
        <checksum file="${mavenUploadDir}/${fullProdName}.pom" forceOverwrite="yes" fileext=".sha1" algorithm="SHA-1" />

        <copy file="./COPYING" toDir="${mavenUploadDir}" />
        <checksum file="${mavenUploadDir}/COPYING" forceOverwrite="yes" fileext=".md5" algorithm="MD5" />
        <checksum file="${mavenUploadDir}/COPYING" forceOverwrite="yes" fileext=".sha1" algorithm="SHA-1" />
    </target>


    <!-- Create a Maven bundle for upload to their repository (include sources). -->
    <target name="-create-maven-archive-sources" depends="-create-maven-archive-common" unless="com.mysql.jdbc.noSources">
        <jar jarfile="${mavenUploadDir}/${fullProdName}-sources.jar"
             basedir="${compiler.output}"
             includes="**/*.java,**/*.properties*,COPYING,README,README.txt"
             excludes="testsuite/**,demo/**,doc/**" />
        <checksum file="${mavenUploadDir}/${fullProdName}-sources.jar" forceOverwrite="yes" fileext=".md5" algorithm="MD5" />
        <checksum file="${mavenUploadDir}/${fullProdName}-sources.jar" forceOverwrite="yes" fileext=".sha1" algorithm="SHA-1" />
    </target>


    <!-- Prepare docs to include in a distribution. -->
    <target name="-bundle-docs" depends="init" if="com.mysql.jdbc.docs.sourcesPresent">
        <copy file="${com.mysql.jdbc.docs.sourceDir}/en/html/connector-j.html" todir="${buildDir}/${fullProdName}/docs" failonerror="false" />
        <copy file="${com.mysql.jdbc.docs.sourceDir}/en/pdf/connector-j.pdf" todir="${buildDir}/${fullProdName}/docs" failonerror="false" />
        <copy file="${com.mysql.jdbc.docs.sourceDir}/en/txt/connector-j.txt" tofile="${buildDir}/${fullProdName}/docs/README.txt" failonerror="false" />
    </target>


    <!-- ********************* -->
    <!-- ***** COMPILING ***** -->
    <!-- ********************* -->


    <!-- Compile the driver including JDBC 3 and JDBC 4+ implementations, JUnit test suite and 'helpers' for third-party software. -->
    <target name="compile"
            description="Compiles driver including JDBC 3 and JDBC 4+ implementations, JUnit test suite and integration 'helpers' for third-party software."
            depends="init, compile-driver, compile-testsuite, compile-integration" />


    <!-- Compile the driver including JDBC 3 and JDBC 4+ implementations only. -->
    <target name="compile-driver"
            description="Compiles driver including JDBC 3 and JDBC 4+ implementations only."
            depends="-compile-driver-jdbc3, -compile-driver-jdbc4" />


    <!-- Compile JDBC 3 implementation. -->
    <target name="-compile-driver-jdbc3" depends="init, -clean-output">
        <echo>Compiling MySQL Connector/J JDBC 3 implementation with '${com.mysql.jdbc.jdk5}' to '${compiler.output}'</echo>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk5.javac}"
               compiler="modern"
               includeantruntime="false"
               source="1.5"
               target="1.5">
            <include name="**/*.java" />
            <exclude name="testsuite/**" />
            <exclude name="com/mysql/jdbc/integration/**" />
            <exclude name="com/mysql/jdbc/log/Log4JLogger.java" />
            <exclude name="**/JDBC4*.java" />
            <exclude name="**/FabricMultiTenantConnectionProvider.java" />
            <exclude name="**/HibernateFabric.java" />
            <exclude name="com/mysql/jdbc/exceptions/jdbc4/*" />
            <classpath refid="project.build.classpath" />
            <compilerarg line="${javac.compilerarg}" />
        </javac>
    </target>


    <!-- Compile JDBC 4+ implementation. -->
    <target name="-compile-driver-jdbc4" depends="-compile-driver-jdbc3">
        <echo>Compiling MySQL Connector/J JDBC 4+ implementation with '${com.mysql.jdbc.jdk8}' to '${compiler.output}'</echo>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk8.javac}"
               compiler="modern"
               includeantruntime="false"
               bootclasspath="${com.mysql.jdbc.jre6.rtjar}"
               source="1.6"
               target="1.6">
            <include name="**/FabricMultiTenantConnectionProvider.java" />
            <include name="**/HibernateFabric.java" />
            <include name="**/JDBC4*.java" />
            <exclude name="**/JDBC42*.java" />
            <include name="com/mysql/jdbc/exceptions/jdbc4/*" />
            <classpath refid="project.build.classpath" />
            <compilerarg line="${javac.compilerarg}" />
        </javac>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk8.javac}"
               compiler="modern"
               includeantruntime="false"
               source="1.8"
               target="1.8">
            <include name="**/JDBC42*.java" />
            <classpath refid="project.build.classpath" />
            <compilerarg line="${javac.compilerarg}" />
        </javac>
    </target>


    <!-- Compile the driver including JDBC 3 and JDBC 4+ implementations and JUnit test suite. -->
    <target name="compile-testsuite"
            description="Compiles driver including JDBC 3 and JDBC 4+ implementations and JUnit test suite."
            depends="init, compile-driver">
        <echo>Compiling MySQL Connector/J testsuite with '${com.mysql.jdbc.jdk5}' to '${compiler.output}'</echo>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk5.javac}"
               compiler="modern"
               includeantruntime="false"
               source="1.5"
               target="1.5">
            <include name="testsuite/**" />
            <exclude name="testsuite/requiresNonRedists/**" />
            <exclude name="testsuite/**/jdbc4*/**" />
            <classpath refid="project.build.classpath" />
            <compilerarg line="${javac.compilerarg}" />
        </javac>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk8.javac}"
               compiler="modern"
               includeantruntime="false"
               bootclasspath="${com.mysql.jdbc.jre6.rtjar}"
               source="1.6"
               target="1.6">
            <include name="testsuite/**/jdbc4/**" />
            <classpath refid="project.build.classpath" />
            <compilerarg line="${javac.compilerarg}" />
        </javac>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk8.javac}"
               compiler="modern"
               includeantruntime="false"
               source="1.8"
               target="1.8">
            <include name="testsuite/**/jdbc42/**" />
            <classpath refid="project.build.classpath" />
            <compilerarg line="${javac.compilerarg}" />
        </javac>
    </target>


    <!-- Compile the driver including JDBC 3 and JDBC 4+ implementations and integration 'helpers' for third-party software. -->
    <target name="compile-integration"
            description="Compiles driver including JDBC 3 and JDBC 4+ implementations and integration 'helpers' for third-party software."
            depends="compile-driver, -compile-integration-c3p0, -compile-integration-jboss, -compile-integration-log4j" />


    <!-- Compile c3p0 integration. -->
    <target name="-compile-integration-c3p0" depends="compile-driver" if="com.mysql.jdbc.c3p0Present">
        <echo>Compiling MySQL Connector/J-c3p0 integration with '${com.mysql.jdbc.jdk5}' to '${compiler.output}'</echo>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk5.javac}"
               compiler="modern"
               includeantruntime="false"
               source="1.5"
               target="1.5">
            <include name="com/mysql/jdbc/integration/c3p0/**" />
            <classpath refid="project.build.classpath" />
        </javac>
    </target>


    <!-- Compile jBoss integration. -->
    <target name="-compile-integration-jboss" depends="compile-driver" if="com.mysql.jdbc.jbossPresent">
        <echo>Compiling MySQL Connector/J-jboss integration with '${com.mysql.jdbc.jdk5}' to '${compiler.output}'</echo>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk5.javac}"
               compiler="modern"
               includeantruntime="false"
               source="1.5"
               target="1.5">
            <include name="com/mysql/jdbc/integration/jboss/**" />
            <classpath refid="project.build.classpath" />
        </javac>
    </target>


    <!-- Compile Log4j integration. -->
    <target name="-compile-integration-log4j" depends="compile-driver" if="com.mysql.jdbc.log4jPresent">
        <echo>Compiling MySQL Connector/J-log4j integration with '${com.mysql.jdbc.jdk5}' to '${compiler.output}'</echo>

        <javac sourcepath=""
               srcdir="${buildDir}/${fullProdName}"
               destdir="${compiler.output}"
               deprecation="off"
               debug="${debug.enable}"
               fork="yes"
               executable="${com.mysql.jdbc.jdk5.javac}"
               compiler="modern"
               includeantruntime="false"
               source="1.5"
               target="1.5">
            <include name="com/mysql/jdbc/log/Log4JLogger.java" />
            <classpath refid="project.build.classpath" />
        </javac>
    </target>


    <!-- ******************* -->
    <!-- ***** CLEANUP ***** -->
    <!-- ******************* -->


    <!-- Delete the build and distribution directories and archives. -->
    <target name="real-clean" description="Deletes the build and distribution directories.">
        <delete dir="${buildDir}" />
        <delete dir="${distDir}" />
    </target>


    <!-- Delete the build directory. -->
    <target name="clean"
            description="Deletes the build directory unless 'com.mysql.jdbc.noCleanBetweenCompiles=yes'."
            unless="${com.mysql.jdbc.noCleanBetweenCompiles}">
        <delete dir="${buildDir}" />
    </target>


    <!-- Delete compiled classes from build directory. -->
    <target name="-clean-output" unless="${com.mysql.jdbc.noCleanBetweenCompiles}">
        <delete>
            <fileset dir="${buildDir}" includes="**/*.class" />
        </delete>
    </target>


    <!-- ************************* -->
    <!-- ***** DOCUMENTATION ***** -->
    <!-- ************************* -->


    <!-- Generate docs for MySQL Connector/J docs web site. -->
    <target name="docs-generate-dynamic-docs"
            description="Generates docs for the MySQL Connector/J docs web site."
            depends="docs-generate-properties-table, docs-generate-error-mapping-table" />


    <!-- Generate the properties table doc for MySQL Connector/J docs web site. -->
    <target name="docs-generate-properties-table"
            description="Generates properties table doc for the MySQL Connector/J docs web site."
            depends="compile-driver">
        <tempfile property="properties-xml" suffix=".xml" />
        <java classname="com.mysql.jdbc.util.PropertiesDocGenerator" output="${properties-xml}" classpath="${buildDir}/${fullProdName}" />
        <copy file="${properties-xml}" tofile="${buildDir}/${fullProdName}/docs/sources/connPropsToDocbook.xml" />
        <delete file="${properties-xml}" />
    </target>


    <!-- Generate the error mapping table doc for MySQL Connector/J docs web site. -->
    <target name="docs-generate-error-mapping-table"
            description="Generates error mapping table doc for the MySQL Connector/J docs web site."
            depends="compile-driver">
        <tempfile property="errorsMapping-xml" suffix=".xml" />
        <java classname="com.mysql.jdbc.util.ErrorMappingsDocGenerator" output="${errorsMapping-xml}" classpath="${buildDir}/${fullProdName}" />
        <copy file="${errorsMapping-xml}" tofile="${buildDir}/${fullProdName}/docs/sources/errorMapToDocbook.xml" />
        <delete file="${errorsMapping-xml}" />
    </target>


    <!-- ******************* -->
    <!-- ***** TESTING ***** -->
    <!-- ******************* -->


    <!-- Run the full test suite, single test set or single test, and compliance test suite, against multiple JVMs and server configs. -->
    <target name="test-all-multi"
            description="Runs the full test suite, single test set or single test, and compliance test suite, against multiple JVMs and server configs."
            depends="compile">
        <delete dir="${buildDir}/junit" />
        <antcall target="test-multijvm" />
        <antcall target="test-compliance-multijvm" />

        <fail message="Tests failed. Check logs and/or reports in '${buildDir}/junit'." if="tests.compliance.failed" />
    </target>


    <!-- Run the full test suite, single test set or named test against multiple JVMs and server configs. -->
    <target name="test-multijvm"
            description="Runs the full test suite, single test set (variable 'test') or named tests (variables 'test' and 'methods') against multiple JVMs and server configs."
            depends="compile">
        <array8 arrayproperty="com.mysql.jdbc.testsuite.jvm" outputproperty="jvm.value" indexproperty="jvm.index">
            <array8 arrayproperty="com.mysql.jdbc.testsuite.url" outputproperty="url.value" indexproperty="url.index">
                <local name="test.run" />
                <condition property="test.run">
                    <and>
                        <isset property="jvm.value" />
                        <isset property="url.value" />
                    </and>
                </condition>
                <antcall target="-test-multijvm-iteration">
                    <param name="jvm.value" value="${jvm.value}" />
                    <param name="url.value" value="${url.value}" />
                    <param name="url.index" value="${url.index}" />
                    <param name="test.mode" value="testsuite" />
                    <param name="test.target" value="test" />
                    <param name="test.run" value="${test.run}" />
                </antcall>
            </array8>
        </array8>
    </target>


    <!-- Run the full test suite, single test set or named tests against one JVM and one server config. -->
    <target name="test"
            description="Runs the full test suite, single test set (variable 'test') or named tests (variables 'test' and 'methods') against one JVM and one server config."
            depends="-testsuite-url-check, -testsuite-jvm-check, compile, -set-test-result-prefix">
        <property name="junit.unitregress.results" value="${junit.results}/${test.result.prefix}/unitregress" />

        <mkdir dir="${junit.unitregress.results}/report" />

        <local name="test.ismethods" />
        <condition property="test.ismethods">
            <and>
                <isset property="test" />
                <isset property="methods" />
            </and>
        </condition>

        <local name="test.message.jdbc3orcommon" />
        <condition property="test.message.jdbc3orcommon"
                   value="Running JDBC 3 unit tests against '${com.mysql.jdbc.testsuite.url.final}' with jvm '${com.mysql.jdbc3.testsuite.jvm.java}'">
            <not>
                <isset property="test" />
            </not>
        </condition>
        <condition property="test.message.jdbc3orcommon"
                   value="Running JDBC unit test '${test}', method(s) '${methods}' against '${com.mysql.jdbc.testsuite.url.final}' with jvm '${com.mysql.jdbc3.testsuite.jvm.java}'"
                   else="Running JDBC unit test '${test}' against '${com.mysql.jdbc.testsuite.url.final}' with jvm '${com.mysql.jdbc3.testsuite.jvm.java}'">
            <isset property="test.ismethods" />
        </condition>
        <echo>${test.message.jdbc3orcommon}</echo>

        <junit printsummary="yes"
               fork="on"
               forkmode="once"
               jvm="${com.mysql.jdbc3.testsuite.jvm.java}"
               errorProperty="tests.failed"
               failureProperty="tests.failed">
            <jvmarg value="-Xmx1024m" />

            <syspropertyset refid="junit.system.properties" />
            <sysproperty key="com.mysql.jdbc.testsuite.url" value="${com.mysql.jdbc.testsuite.url.final}" />
            <sysproperty key="jcov.template" value="${com.mysql.jdbc.coverage.result.dir.final}/template.xml"/>
            <sysproperty key="jcov.file" value="${com.mysql.jdbc.coverage.result.dir.final}/${com.mysql.jdbc.coverage.result.name.final}"/>

            <classpath>
                <pathelement location="${com.mysql.jdbc.extra.libs}/jcov/jcov_file_saver.jar" />
                <fileset dir="${com.mysql.jdbc.extra.libs}">
                    <include name="**/*.jar" />
                </fileset>
                <fileset dir="${buildDir}/${fullProdName}/lib">
                    <include name="**/*.jar" />
                </fileset>
                <pathelement location="${buildDir}/${fullProdName}-instr" />
                <pathelement location="${buildDir}/${fullProdName}" />
                <pathelement path="${java.class.path}" />
            </classpath>

            <formatter type="xml" />

            <test if="${test.ismethods}" name="${test}" methods="${methods}" todir="${junit.unitregress.results}" />

            <test if="test" unless="methods" name="${test}" todir="${junit.unitregress.results}" />

            <batchtest unless="test" todir="${junit.unitregress.results}">
                <fileset dir="${buildDir}/${fullProdName}">
                    <include name="**/*Test.java" />
                    <exclude name="**/fabric/*.java" />
                    <exclude name="**/perf/*.java" />
                    <exclude name="**/jdbc4*/*Test.java" />
                </fileset>
            </batchtest>
        </junit>

        <local name="test.message.jdbc4" />
        <condition property="test.message.jdbc4"
                   value="Running JDBC 4+(&lt;4.2) unit tests against '${com.mysql.jdbc.testsuite.url.final}' with jvm '${com.mysql.jdbc4.testsuite.jvm.java}'"
                   else="">
            <not>
                <isset property="test" />
            </not>
        </condition>
        <echo>${test.message.jdbc4}</echo>

        <junit printsummary="yes"
               fork="on"
               forkmode="once"
               jvm="${com.mysql.jdbc4.testsuite.jvm.java}"
               errorProperty="tests.failed"
               failureProperty="tests.failed">
            <jvmarg value="-Xmx1024m" />

            <syspropertyset refid="junit.system.properties" />
            <sysproperty key="com.mysql.jdbc.testsuite.url" value="${com.mysql.jdbc.testsuite.url.final}" />
            <sysproperty key="jcov.template" value="${com.mysql.jdbc.coverage.result.dir.final}/template.xml"/>
            <sysproperty key="jcov.file" value="${com.mysql.jdbc.coverage.result.dir.final}/${com.mysql.jdbc.coverage.result.name.final}"/>

            <classpath>
                <pathelement location="${com.mysql.jdbc.extra.libs}/jcov/jcov_file_saver.jar" />
                <fileset dir="${com.mysql.jdbc.extra.libs}">
                    <include name="**/*.jar" />
                </fileset>
                <fileset dir="${buildDir}/${fullProdName}/lib">
                    <include name="**/*.jar" />
                </fileset>
                <pathelement location="${buildDir}/${fullProdName}-instr" />
                <pathelement location="${buildDir}/${fullProdName}" />
                <pathelement path="${java.class.path}" />
            </classpath>

            <formatter type="xml" />

            <batchtest unless="test" todir="${junit.unitregress.results}">
                <fileset dir="${buildDir}/${fullProdName}">
                    <include name="**/jdbc4/*Test.java" />
                </fileset>
            </batchtest>
        </junit>

        <local name="test.message.jdbc42" />
        <condition property="test.message.jdbc42"
                   value="Running JDBC 4.2 unit tests against '${com.mysql.jdbc.testsuite.url.final}' with jvm '${com.mysql.jdbc42.testsuite.jvm.java}'"
                   else="">
            <not>
                <isset property="test" />
            </not>
        </condition>
        <echo>${test.message.jdbc42}</echo>

        <junit printsummary="yes"
               fork="on"
               forkmode="once"
               jvm="${com.mysql.jdbc42.testsuite.jvm.java}"
               errorProperty="tests.failed"
               failureProperty="tests.failed">
            <jvmarg value="-Xmx1024m" />

            <syspropertyset refid="junit.system.properties" />
            <sysproperty key="com.mysql.jdbc.testsuite.url" value="${com.mysql.jdbc.testsuite.url.final}" />
            <sysproperty key="jcov.template" value="${com.mysql.jdbc.coverage.result.dir.final}/template.xml"/>
            <sysproperty key="jcov.file" value="${com.mysql.jdbc.coverage.result.dir.final}/${com.mysql.jdbc.coverage.result.name.final}"/>

            <classpath>
                <pathelement location="${com.mysql.jdbc.extra.libs}/jcov/jcov_file_saver.jar" />
                <fileset dir="${com.mysql.jdbc.extra.libs}">
                    <include name="**/*.jar" />
                </fileset>
                <fileset dir="${buildDir}/${fullProdName}/lib">
                    <include name="**/*.jar" />
                </fileset>
                <pathelement location="${buildDir}/${fullProdName}-instr" />
                <pathelement location="${buildDir}/${fullProdName}" />
                <pathelement path="${java.class.path}" />
            </classpath>

            <formatter type="xml" />

            <batchtest unless="test" todir="${junit.unitregress.results}">
                <fileset dir="${buildDir}/${fullProdName}">
                    <include name="**/jdbc42/*Test.java" />
                </fileset>
            </batchtest>
        </junit>

        <junitreport todir="${junit.unitregress.results}/report">
            <fileset dir="${junit.unitregress.results}">
                <include name="**/TEST-*.xml" />
            </fileset>
            <report format="frames" todir="${junit.unitregress.results}/report" />
        </junitreport>

        <!-- Don't fail the build if we're doing multi-tests. -->
        <fail message="Tests failed. Check logs and/or reports in '${junit.results}'.">
            <condition>
                <and>
                    <equals arg1="${test.result.prefix}" arg2="" />
                    <isset property="tests.failed" />
                </and>
            </condition>
        </fail>

        <local name="test.message.dontfail" />
        <condition property="test.message.dontfail" value="Skipping test failures check because of multi-test..." else="">
            <not>
                <equals arg1="${test.result.prefix}" arg2="" />
            </not>
        </condition>
        <echo>${test.message.dontfail}</echo>
    </target>


    <!-- Run compliance test suite against multiple JVMs and server configs. 
         The JDBC compliance test suite is not shipped with MySQL Connector/J as it is not licensable except from Oracle.
         The properties com.mysql.jdbc.compliance.url.[1..8] and jdbc.compliance.location must be set prior to running this test. -->
    <target name="test-compliance-multijvm" description="Runs compliance test suite against multiple JVMs and server configs." depends="compile">
        <array8 arrayproperty="com.mysql.jdbc.testsuite.jvm" outputproperty="jvm.value" indexproperty="jvm.index">
            <array8 arrayproperty="com.mysql.jdbc.compliance.url" outputproperty="url.value" indexproperty="url.index">
                <local name="test.run" />
                <condition property="test.run">
                    <and>
                        <isset property="jvm.value" />
                        <isset property="url.value" />
                    </and>
                </condition>
                <antcall target="-test-multijvm-iteration">
                    <param name="jvm.value" value="${jvm.value}" />
                    <param name="url.value" value="${url.value}" />
                    <param name="url.index" value="${url.index}" />
                    <param name="test.mode" value="compliance" />
                    <param name="test.target" value="test-compliance" />
                    <param name="test.run" value="${test.run}" />
                </antcall>
            </array8>
        </array8>
    </target>


    <!-- Run compliance test suite against one JVMs and one server config. 
         The JDBC compliance test suite is not shipped with MySQL Connector/J as it is not licensible except from Oracle.
         The properties com.mysql.jdbc.compliance.url and jdbc.compliance.location must be set prior to running this test. -->
    <target name="test-compliance"
            description="Runs compliance test suite against one JVMs and one server config."
            depends="-compliance-url-check, -testsuite-jvm-check, compile, -set-test-result-prefix">
        <property name="junit.compliance.results" value="${junit.results}/${test.result.prefix}/compliance" />

        <mkdir dir="${junit.compliance.results}/report" />

        <echo>Running compliance test suite against '${com.mysql.jdbc.compliance.url.final}' with jvm '${com.mysql.jdbc3.testsuite.jvm.java}'</echo>

        <junit printsummary="yes"
               fork="on"
               forkmode="once"
               jvm="${com.mysql.jdbc3.testsuite.jvm.java}"
               errorProperty="tests.compliance.failed"
               failureProperty="tests.compliance.failed">
            <jvmarg value="-Xmx1024m" />

            <syspropertyset refid="junit.system.properties" />
            <sysproperty key="com.mysql.jdbc.compliance.url" value="${com.mysql.jdbc.compliance.url.final}" />

            <classpath>
                <fileset dir="${com.mysql.jdbc.extra.libs}">
                    <include name="**/*.jar" />
                </fileset>
                <fileset dir="${buildDir}/${fullProdName}/lib">
                    <include name="**/*.jar" />
                </fileset>
                <pathelement location="${buildDir}/${fullProdName}" />
                <pathelement path="${java.class.path}" />
                <pathelement location="${jdbc.compliance.location}" />
            </classpath>

            <formatter type="xml" />

            <test todir="${junit.compliance.results}" name="com.mysql.jdbc.compliance.tests.BatchUpdateTest" />
            <test todir="${junit.compliance.results}" name="com.mysql.jdbc.compliance.tests.ConnectionTest" />
            <test todir="${junit.compliance.results}" name="com.mysql.jdbc.compliance.tests.DatabaseMetaDataTest" />
            <test todir="${junit.compliance.results}" name="com.mysql.jdbc.compliance.tests.EscapeSyntaxTest" />
            <test todir="${junit.compliance.results}" name="com.mysql.jdbc.compliance.tests.PreparedStatementTest" />
            <test todir="${junit.compliance.results}" name="com.mysql.jdbc.compliance.tests.ResultSetMetadataTest" />
            <test todir="${junit.compliance.results}" name="com.mysql.jdbc.compliance.tests.ResultSetTest" />
            <test todir="${junit.compliance.results}" name="com.mysql.jdbc.compliance.tests.StatementTest" />
        </junit>

        <junitreport todir="${junit.compliance.results}/report">
            <fileset dir="${junit.compliance.results}">
                <include name="**/TEST-*.xml" />
            </fileset>
            <report format="frames" todir="${junit.compliance.results}/report" />
        </junitreport>

        <!-- Don't fail the build if we're doing multi-tests. -->
        <fail message="Tests failed. Check logs and/or reports in '${junit.compliance.results}'.">
            <condition>
                <and>
                    <equals arg1="${test.result.prefix}" arg2="" />
                    <isset property="tests.compliance.failed" />
                </and>
            </condition>
        </fail>

        <local name="test.message.dontfail" />
        <condition property="test.message.dontfail" value="Skipping test failures check because of multi-test..." else="">
            <not>
                <equals arg1="${test.result.prefix}" arg2="" />
            </not>
        </condition>
        <echo>${test.message.dontfail}</echo>
    </target>


    <!-- Run a generic multijvm iteration. -->
    <target name="-test-multijvm-iteration" if="${test.run}">
        <make-output-hier jvm="${jvm.value}" jdbcUrl="${url.value}" jdbcUrlIter="${url.index}" junitOutput="${junit.results}" />

        <local name="junit.output" />
        <loadfile srcfile="${junit.results}/hier" property="junit.output" />

        <antcall target="${test.target}">
            <param name="com.mysql.jdbc.testsuite.jvm.internal" value="${jvm.value}" />
            <param name="com.mysql.jdbc.${test.mode}.url.internal" value="${url.value}" />
            <param name="com.mysql.jdbc.noCleanBetweenCompiles" value="yes" />
            <param name="test.result.prefix" value="/${junit.output}" />
        </antcall>
    </target>


    <!-- Set the path where the test results will be stored -->
    <target name="-set-test-result-prefix" unless="${test.result.prefix}">
        <property name="test.result.prefix" value="" />
    </target>


    <!-- ********************************* -->
    <!-- ***** TESTING CODE COVERAGE ***** -->
    <!-- ********************************* -->


    <target name="test-coverage" depends="-jcov-instrument, test" description="Runs tests collecting coverage results."/>


    <target name="-jcov-instrument" depends="compile-driver, -set-test-coverage-detaults">
        <mkdir dir="${buildDir}/${fullProdName}-instr"/>
        <mkdir dir="${com.mysql.jdbc.coverage.result.dir.final}"/>
        <delete file="${com.mysql.jdbc.coverage.result.dir.final}/template.xml"/>

        <java fork="true" jvm="${com.mysql.jdbc.jdk8}/bin/java" classname="com.sun.tdk.jcov.Instr" classpathref="project.build.classpath">
            <arg line="-e testsuite.* -e demo.* -t ${com.mysql.jdbc.coverage.result.dir.final}/template.xml -output ${buildDir}/${fullProdName}-instr ${buildDir}/${fullProdName}" />
        </java>
    </target>


    <target name="-set-test-coverage-detaults">
        <condition property="com.mysql.jdbc.coverage.result.dir.final" value="${com.mysql.jdbc.coverage.result.dir}" else="${buildDir}/coverage">
            <isset property="com.mysql.jdbc.coverage.result.dir" />
        </condition>
        <condition property="com.mysql.jdbc.coverage.result.name.final" value="${com.mysql.jdbc.coverage.result.name}" else="result.xml">
            <isset property="com.mysql.jdbc.coverage.result.name" />
        </condition>
    </target>


    <!-- *********************************** -->
    <!-- ***** REPORTING CODE COVERAGE ***** -->
    <!-- *********************************** -->


    <target name="report-coverage" depends="-jcov-merge, -set-report-coverage-detaults" description="Merges coverage results and creates HTML coverage report.">
        <mkdir dir="${com.mysql.jdbc.coverage.report.dir.final}"/>
        <java fork="true" jvm="${com.mysql.jdbc.jdk8}/bin/java" classname="com.sun.tdk.jcov.RepGen" classpathref="project.build.classpath">
            <arg line="-e testsuite.* -e demo.* -src ${sourceDir} -o ${com.mysql.jdbc.coverage.report.dir.final} ${com.mysql.jdbc.coverage.merge.result.final}" />
        </java>
    </target>


    <target name="-jcov-merge" depends="-set-report-coverage-detaults" if="com.mysql.jdbc.coverage.merge.files">
        <java fork="true" jvm="${com.mysql.jdbc.jdk8}/bin/java" classname="com.sun.tdk.jcov.Merger" classpathref="project.build.classpath">
            <arg line="-o ${com.mysql.jdbc.coverage.merge.result.final} ${com.mysql.jdbc.coverage.merge.files}" />
        </java>
    </target>


    <target name="-set-report-coverage-detaults" depends="-set-test-coverage-detaults">
        <condition property="com.mysql.jdbc.coverage.merge.result.final" value="${com.mysql.jdbc.coverage.merge.result}" else="${com.mysql.jdbc.coverage.result.dir.final}/result.xml">
            <isset property="com.mysql.jdbc.coverage.merge.result" />
        </condition>
        <condition property="com.mysql.jdbc.coverage.report.dir.final" value="${com.mysql.jdbc.coverage.report.dir}" else="${com.mysql.jdbc.coverage.result.dir.final}/report">
            <isset property="com.mysql.jdbc.coverage.report.dir" />
        </condition>
    </target>


    <!-- ***************************** -->
    <!-- ***** MACRO DEFINITIONS ***** -->
    <!-- ***************************** -->


    <!-- Executes actions for each element of array properties (properties ending with '.N') of length 8. -->
    <macrodef name="array8">
        <attribute name="arrayproperty" />
        <attribute name="outputproperty" />
        <attribute name="indexproperty" />
        <element name="job" implicit="true" />
        <sequential>
            <array-job arrayproperty="@{arrayproperty}" outputproperty="@{outputproperty}" indexproperty="@{indexproperty}" indexvalue="1">
                <job />
            </array-job>
            <array-job arrayproperty="@{arrayproperty}" outputproperty="@{outputproperty}" indexproperty="@{indexproperty}" indexvalue="2">
                <job />
            </array-job>
            <array-job arrayproperty="@{arrayproperty}" outputproperty="@{outputproperty}" indexproperty="@{indexproperty}" indexvalue="3">
                <job />
            </array-job>
            <array-job arrayproperty="@{arrayproperty}" outputproperty="@{outputproperty}" indexproperty="@{indexproperty}" indexvalue="4">
                <job />
            </array-job>
            <array-job arrayproperty="@{arrayproperty}" outputproperty="@{outputproperty}" indexproperty="@{indexproperty}" indexvalue="5">
                <job />
            </array-job>
            <array-job arrayproperty="@{arrayproperty}" outputproperty="@{outputproperty}" indexproperty="@{indexproperty}" indexvalue="6">
                <job />
            </array-job>
            <array-job arrayproperty="@{arrayproperty}" outputproperty="@{outputproperty}" indexproperty="@{indexproperty}" indexvalue="7">
                <job />
            </array-job>
            <array-job arrayproperty="@{arrayproperty}" outputproperty="@{outputproperty}" indexproperty="@{indexproperty}" indexvalue="8">
                <job />
            </array-job>
        </sequential>
    </macrodef>


    <!-- Executes actions for array type macros, defined as elements nested in top level array macro calls. -->
    <macrodef name="array-job">
        <attribute name="arrayproperty" />
        <attribute name="outputproperty" />
        <attribute name="indexproperty" />
        <attribute name="indexvalue" />
        <element name="job" implicit="true" />
        <sequential>
            <local name="@{outputproperty}" />
            <condition property="@{outputproperty}" value="${@{arrayproperty}.@{indexvalue}}">
                <isset property="@{arrayproperty}.@{indexvalue}" />
            </condition>
            <local name="@{indexproperty}" />
            <condition property="@{indexproperty}" value="@{indexvalue}" else="0">
                <isset property="@{arrayproperty}.@{indexvalue}" />
            </condition>
            <job />
        </sequential>
    </macrodef>


    <!-- Makes an output directory hierarchy based on MySQL server version, OS information and JVM version. -->
    <macrodef name="make-output-hier">
        <attribute name="jvm" />
        <attribute name="jdbcUrl" />
        <attribute name="jdbcUrlIter" />
        <attribute name="junitOutput" />

        <sequential>
            <local name="jvm.java" />
            <property name="jvm.java" value="@{jvm}/bin/java" />

            <local name="jvm.version" />
            <exec executable="${jvm.java}" outputproperty="jvm.version" failonerror="false" failifexecutionfails="false" resultproperty="jvmcheckexitstatus">
                <arg value="-version" />
            </exec>

            <fail message="The provided JVM reference is invalid '@{jvm}'. Set the path to a valid JVM(s) (JRE or JDK) home in the properties 'com.mysql.jdbc.testsuite.jvm.[1..8]'.">
                <condition>
                    <not>
                        <and>
                            <equals arg1="${jvmcheckexitstatus}" arg2="0" />
                            <matches string="${jvm.version}" pattern="^java version &quot;\d+\.\d+\.\d+_\d+&quot;.*$" casesensitive="true" multiline="true" />
                        </and>
                    </not>
                </condition>
            </fail>

            <java fork="true" jvm="${jvm.java}" classname="com.mysql.jdbc.util.VersionFSHierarchyMaker">
                <jvmarg value="-Xmx1024m" />

                <sysproperty key="com.mysql.jdbc.testsuite.url" value="@{jdbcUrl}" />

                <classpath>
                    <fileset dir="${com.mysql.jdbc.extra.libs}">
                        <include name="**/*.jar" />
                    </fileset>
                    <fileset dir="${buildDir}/${fullProdName}/lib">
                        <include name="**/*.jar" />
                    </fileset>
                    <pathelement location="${buildDir}/${fullProdName}" />
                    <pathelement path="${java.class.path}" />
                </classpath>

                <arg line="@{junitOutput} @{junitOutput}/hier @{jdbcUrlIter}" />
            </java>
        </sequential>
    </macrodef>


    <!-- ********************************* -->
    <!-- ***** FABRIC TESTS AND DEMO ***** -->
    <!-- ********************************* -->


    <!-- 'test' and 'demo' targets for Fabric intentionally don't depend on 'build'.
         This allows building and testing code with the environmental JVM. -->

    <!-- Test Fabric setup. -->
    <target name="test-fabric-setup" description="Tests Fabric setup." depends="-extra-libs-check">
        <java fork="on" classname="testsuite.fabric.SetupFabricTestsuite" dir="${buildDir}/${fullProdName}">
            <sysproperty key="com.mysql.fabric.testsuite.username" value="${com.mysql.fabric.testsuite.username}" />
            <sysproperty key="com.mysql.fabric.testsuite.password" value="${com.mysql.fabric.testsuite.password}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.host" value="${com.mysql.fabric.testsuite.global.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.port" value="${com.mysql.fabric.testsuite.global.port}" />
        </java>
    </target>


    <!-- Run test suite for Fabric. -->
    <target name="test-fabric" description="Runs the test suite for Fabric." depends="test-fabric-setup">
        <junit printsummary="yes" fork="on" forkmode="once">
            <sysproperty key="com.mysql.fabric.testsuite.hostname" value="${com.mysql.fabric.testsuite.hostname}" />
            <sysproperty key="com.mysql.fabric.testsuite.port" value="${com.mysql.fabric.testsuite.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.fabricUsername" value="${com.mysql.fabric.testsuite.fabricUsername}" />
            <sysproperty key="com.mysql.fabric.testsuite.fabricPassword" value="${com.mysql.fabric.testsuite.fabricPassword}" />
            <sysproperty key="com.mysql.fabric.testsuite.username" value="${com.mysql.fabric.testsuite.username}" />
            <sysproperty key="com.mysql.fabric.testsuite.password" value="${com.mysql.fabric.testsuite.password}" />
            <sysproperty key="com.mysql.fabric.testsuite.database" value="${com.mysql.fabric.testsuite.database}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.host" value="${com.mysql.fabric.testsuite.global.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.port" value="${com.mysql.fabric.testsuite.global.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard1.host" value="${com.mysql.fabric.testsuite.shard1.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard1.port" value="${com.mysql.fabric.testsuite.shard1.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard2.host" value="${com.mysql.fabric.testsuite.shard2.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard2.port" value="${com.mysql.fabric.testsuite.shard2.port}" />

            <classpath>
                <fileset dir="${com.mysql.jdbc.extra.libs}/hibernate4">
                    <include name="**/*.jar" />
                </fileset>
                <fileset dir="${buildDir}/${fullProdName}/lib">
                    <include name="**/*.jar" />
                </fileset>
                <pathelement location="${buildDir}/${fullProdName}" />
                <pathelement path="${java.class.path}" />
            </classpath>

            <formatter type="brief" />

            <test if="test" name="${test}" />

            <batchtest unless="test">
                <fileset dir="${buildDir}/${fullProdName}">
                    <include name="**/fabric/**/Test*.java" />
                    <exclude name="**/fabric/**/TestHashSharding.java" />
                    <exclude name="**/fabric/**/TestHABasics.java" />
                </fileset>
            </batchtest>
        </junit>
    </target>


    <!-- Launch a Fabric demo. -->
    <target name="demo-fabric" description="Launches a Fabric demo." depends="demo-fabric-client1, demo-fabric-employees-jdbc" />


    <!-- Launch a client component from the Fabric demo. -->
    <target name="demo-fabric-client1" description="Launches a client component from the Fabric demo." depends="-extra-libs-check">
        <java fork="on" classname="demo.fabric.Client1_Fabric" dir="${buildDir}/${fullProdName}">
            <sysproperty key="com.mysql.fabric.testsuite.hostname" value="${com.mysql.fabric.testsuite.hostname}" />
            <sysproperty key="com.mysql.fabric.testsuite.port" value="${com.mysql.fabric.testsuite.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.fabricUsername" value="${com.mysql.fabric.testsuite.fabricUsername}" />
            <sysproperty key="com.mysql.fabric.testsuite.fabricPassword" value="${com.mysql.fabric.testsuite.fabricPassword}" />
            <sysproperty key="com.mysql.fabric.testsuite.username" value="${com.mysql.fabric.testsuite.username}" />
            <sysproperty key="com.mysql.fabric.testsuite.password" value="${com.mysql.fabric.testsuite.password}" />
            <sysproperty key="com.mysql.fabric.testsuite.database" value="${com.mysql.fabric.testsuite.database}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.host" value="${com.mysql.fabric.testsuite.global.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.port" value="${com.mysql.fabric.testsuite.global.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard1.host" value="${com.mysql.fabric.testsuite.shard1.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard1.port" value="${com.mysql.fabric.testsuite.shard1.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard2.host" value="${com.mysql.fabric.testsuite.shard2.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard2.port" value="${com.mysql.fabric.testsuite.shard2.port}" />
        </java>
    </target>


    <!-- Launch an employees component from the Fabric demo. -->
    <target name="demo-fabric-employees-jdbc" description="Launches a employees component from the Fabric demo." depends="-extra-libs-check">
        <java fork="on" classname="demo.fabric.EmployeesJdbc" dir="${buildDir}/${fullProdName}">
            <sysproperty key="com.mysql.fabric.testsuite.hostname" value="${com.mysql.fabric.testsuite.hostname}" />
            <sysproperty key="com.mysql.fabric.testsuite.port" value="${com.mysql.fabric.testsuite.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.fabricUsername" value="${com.mysql.fabric.testsuite.fabricUsername}" />
            <sysproperty key="com.mysql.fabric.testsuite.fabricPassword" value="${com.mysql.fabric.testsuite.fabricPassword}" />
            <sysproperty key="com.mysql.fabric.testsuite.username" value="${com.mysql.fabric.testsuite.username}" />
            <sysproperty key="com.mysql.fabric.testsuite.password" value="${com.mysql.fabric.testsuite.password}" />
            <sysproperty key="com.mysql.fabric.testsuite.database" value="${com.mysql.fabric.testsuite.database}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.host" value="${com.mysql.fabric.testsuite.global.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.port" value="${com.mysql.fabric.testsuite.global.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard1.host" value="${com.mysql.fabric.testsuite.shard1.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard1.port" value="${com.mysql.fabric.testsuite.shard1.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard2.host" value="${com.mysql.fabric.testsuite.shard2.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard2.port" value="${com.mysql.fabric.testsuite.shard2.port}" />
        </java>
    </target>


    <!-- Launch a Hibernate component from the Fabric demo. -->
    <target name="demo-fabric-hibernate" description="Launches a Hibernate component from the Fabric demo." depends="-extra-libs-check">
        <java fork="on" classname="demo.fabric.HibernateFabric" dir="${buildDir}/${fullProdName}">
            <sysproperty key="com.mysql.fabric.testsuite.hostname" value="${com.mysql.fabric.testsuite.hostname}" />
            <sysproperty key="com.mysql.fabric.testsuite.port" value="${com.mysql.fabric.testsuite.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.fabricUsername" value="${com.mysql.fabric.testsuite.fabricUsername}" />
            <sysproperty key="com.mysql.fabric.testsuite.fabricPassword" value="${com.mysql.fabric.testsuite.fabricPassword}" />
            <sysproperty key="com.mysql.fabric.testsuite.username" value="${com.mysql.fabric.testsuite.username}" />
            <sysproperty key="com.mysql.fabric.testsuite.password" value="${com.mysql.fabric.testsuite.password}" />
            <sysproperty key="com.mysql.fabric.testsuite.database" value="${com.mysql.fabric.testsuite.database}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.host" value="${com.mysql.fabric.testsuite.global.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.global.port" value="${com.mysql.fabric.testsuite.global.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard1.host" value="${com.mysql.fabric.testsuite.shard1.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard1.port" value="${com.mysql.fabric.testsuite.shard1.port}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard2.host" value="${com.mysql.fabric.testsuite.shard2.host}" />
            <sysproperty key="com.mysql.fabric.testsuite.shard2.port" value="${com.mysql.fabric.testsuite.shard2.port}" />

            <classpath>
                <fileset dir="${com.mysql.jdbc.extra.libs}/hibernate4">
                    <include name="**/*.jar" />
                </fileset>
                <fileset dir="src/lib">
                    <include name="**/*.jar" />
                </fileset>
                <dirset dir="${buildDir}/${fullProdName}" />
            </classpath>
        </java>
    </target>
</project>