Summary:             Official JDBC driver for MySQL
Name:                mysql-connector-java
Version:             8.0.15
Release:             1
Epoch:               1
License:             GPLv2 with exceptions
URL:                 http://dev.mysql.com/downloads/connector/j/
Source0:             https://github.com/mysql/mysql-connector-j/archive/%{version}.tar.gz
Patch3:              java-version-detection.patch
Patch4:              remove-coverage-test.patch

BuildArch:           noarch
BuildRequires:       ant >= 1.6.0 ant-contrib >= 1.0 ant-junit apache-commons-logging c3p0 git
BuildRequires:       hibernate java-devel >= 1:1.6.0 javapackages-local jta >= 1.0 junit
BuildRequires:       protobuf-java slf4j
Requires:            jta >= 1.0 slf4j

%description
MySQL Connector/J is a native Java driver that converts JDBC (Java Database
Connectivity) calls into the network protocol used by the MySQL database.
It lets developers working with the Java programming language easily build
programs and applets that interact with MySQL and connect all corporate
data, even in a heterogeneous environment. MySQL Connector/J is a Type
IV JDBC driver and has a complete JDBC feature set that supports the
capabilities of MySQL.

%prep
%setup -q -n mysql-connector-j-%{version}

for file in README README.md; do
 sed -i.orig 's|\r||g' $file
 touch -r $file.orig $file
 rm $file.orig
done
sed -i 's/>@.*</>%{version}</' src/build/misc/pom.xml
%patch3 -p1
%patch4 -p1

%build
export CLASSPATH=$(build-classpath jdbc-stdext jta junit slf4j commons-logging.jar)
rm -rf src/main/user-impl/java/com/mysql/cj/jdbc/integration/jboss
rm src/test/java/testsuite/regression/ConnectionRegressionTest.java
rm src/test/java/testsuite/regression/DataSourceRegressionTest.java
rm src/test/java/testsuite/simple/StatementsTest.java
ant -Dcom.mysql.cj.build.jdk=%{java_home} \
    -Dcom.mysql.cj.extra.libs=/usr/share/java \
    test dist

%install
%mvn_file mysql:mysql-connector-java %{name}
%mvn_artifact src/build/misc/pom.xml build/%{name}-%{version}-SNAPSHOT/%{name}-%{version}-SNAPSHOT.jar
%mvn_install

%files -f .mfiles
%doc CHANGES README README.md
%license LICENSE

%changelog
* Fri Jul 24 2020 leiju <leiju4@huawei.com> - 8.0.15-1
- Package init
