ant编译mysql驱动

修改驱动源码后需要重新编译构建,由于mysql编译需要两个jdk版本且还需要hibernate4和junit,这里记录下。

  • 安装ant。
  • 配置两个jdk,5和8。并修改build.xml配置,如下:
    <property name="com.mysql.jdbc.jdk5" value="/usr/java/jdk1.5.0_15" />
    <property name="com.mysql.jdbc.jdk8" value="/home/vagrant/java/jdk1.8.0_73" />
  • 上传hibernate4必须包到src/lib/hibernate4/下。
  • 上传junit包到src/lib/下。
  • 可能会出现如下报错,这个是jdk的bug,用的jdk版本是jdk-1_5_0_15,需要使用jdk1.5.0_22。
compile-testsuite:
     [echo] Compiling MySQL Connector/J testsuite with '/usr/java/jdk1.5.0_15' to './build/mysql-connector-java-5.1.40-SNAPSHOT'
    [javac] Compiling 62 source files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT
    [javac] An exception has occurred in the compiler (1.5.0_15). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
    [javac] java.lang.AssertionError: {rawtypes}
    [javac]     at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.visitArray(TreeMaker.java:634)
    [javac]     at com.sun.tools.javac.code.Attribute$Array.accept(Attribute.java:124)
    [javac]     at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.translate(TreeMaker.java:637)
    [javac]     at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.visitCompoundInternal(TreeMaker.java:628)
    [javac]     at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.translate(TreeMaker.java:641)
    [javac]     at com.sun.tools.javac.tree.TreeMaker.Annotation(TreeMaker.java:649)
    [javac]     at com.sun.tools.javac.tree.TreeMaker.Annotations(TreeMaker.java:570)
    [javac]     at com.sun.tools.javac.tree.TreeMaker.VarDef(TreeMaker.java:554)
    [javac]     at com.sun.tools.javac.comp.Lower.visitIterableForeachLoop(Lower.java:2892)
    [javac]     at com.sun.tools.javac.comp.Lower.visitForeachLoop(Lower.java:2755)
    [javac]     at com.sun.tools.javac.tree.Tree$ForeachLoop.accept(Tree.java:597)
    [javac]     at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881)
    [javac]     at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:54)
    [javac]     at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:145)
    [javac]     at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:2927)
    <property name="com.mysql.jdbc.jdk5" value="/usr/java/jdk1.5.0_22" />
    <property name="com.mysql.jdbc.jdk8" value="/home/vagrant/java/jdk1.8.0_73" />
  • 执行ant成功编译。
[root@hb-localhost m2o-mysql-connector]# ant
Buildfile: /home/vagrant/m2o-proxy/m2o-mysql-connector/build.xml

-jdk5-check:

-jdk8-check:

-jre6-rtjar-check:

-compiler-check:

clean:
   [delete] Deleting directory /home/vagrant/m2o-proxy/m2o-mysql-connector/build

-init-copy-common:
    [mkdir] Created dir: /home/vagrant/m2o-proxy/m2o-mysql-connector/build
     [copy] Copying 364 files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT
     [copy] Copied 52 empty directories to 1 empty directory under /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT
     [copy] Copying 13 files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT

-replace-headers-commercial:

-init-copy:

-extra-libs-check:

-init-filter-license:

-init-no-crypto:

init:

-clean-output:

-compile-driver-jdbc3:
     [echo] Compiling MySQL Connector/J JDBC 3 implementation with '/home/vagrant/java/jdk1.5.0_22' to './build/mysql-connector-java-5.1.40-SNAPSHOT'
    [javac] Compiling 218 source files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT

-compile-driver-jdbc4:
     [echo] Compiling MySQL Connector/J JDBC 4+ implementation with '/home/vagrant/java/jdk1.8.0_73' to './build/mysql-connector-java-5.1.40-SNAPSHOT'
    [javac] Compiling 41 source files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
    [javac] 1 warning
    [javac] Compiling 8 source files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT

compile-driver:

compile-testsuite:
     [echo] Compiling MySQL Connector/J testsuite with '/home/vagrant/java/jdk1.5.0_22' to './build/mysql-connector-java-5.1.40-SNAPSHOT'
    [javac] Compiling 62 source files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT
    [javac] Compiling 5 source files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
    [javac] 1 warning
    [javac] Compiling 4 source files to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT

-compile-integration-c3p0:
     [echo] Compiling MySQL Connector/J-c3p0 integration with '/home/vagrant/java/jdk1.5.0_22' to './build/mysql-connector-java-5.1.40-SNAPSHOT'
    [javac] Compiling 1 source file to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT

-compile-integration-jboss:
     [echo] Compiling MySQL Connector/J-jboss integration with '/home/vagrant/java/jdk1.5.0_22' to './build/mysql-connector-java-5.1.40-SNAPSHOT'
    [javac] Compiling 1 source file to /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT

-compile-integration-log4j:

compile-integration:

compile:

dist:
    [mkdir] Created dir: /home/vagrant/m2o-proxy/m2o-mysql-connector/build/META-INF
    [mkdir] Created dir: /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT/META-INF/services
      [jar] Building jar: /home/vagrant/m2o-proxy/m2o-mysql-connector/build/mysql-connector-java-5.1.40-SNAPSHOT/mysql-connector-java-5.1.40-SNAPSHOT-bin.jar

BUILD SUCCESSFUL
Total time: 52 seconds
上一篇:mybatis example使用 and和or联合查询(转)


下一篇:JAVA设计模式之责任链模式