%global debug_package %nil
Name:                sqlite-jdbc
Version:             3.15.1
Release:             1
Summary:             SQLite JDBC library
License:             ASL 2.0 and BSD and ISC
URL:                 https://github.com/xerial/sqlite-jdbc
Source0:             https://github.com/xerial/sqlite-jdbc/archive/%{version}/sqlite-jdbc-%{version}.tar.gz
Patch0:              sqlite-jdbc-3.15.1-build.patch
BuildRequires:       gcc maven-local mvn(junit:junit) mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires:       mvn(org.apache.maven.plugins:maven-antrun-plugin)
BuildRequires:       mvn(org.sonatype.oss:oss-parent:pom:) sqlite-devel
%description
SQLite JDBC, is a library for accessing and
creating SQLite database files in Java.

%package javadoc
Summary:             Javadoc for %{name}
BuildArch:           noarch
%description javadoc
This package contains javadoc for %{name}.

%prep
%setup -q -n %{name}-%{version}
find . -name "*.class" -delete
find . -name "*.jar" ! -name "testdb.jar" -delete
find -name "*.jnilib" -print -delete
find -name "*.dll" -print -delete
find -name "*.so" -print -delete
find -name "*.h" -print -delete
rm -r archive/* docker/*
rm -r src/test/java/org/sqlite/ExtensionTest.java
sed -i '/ExtensionTest/d' src/test/java/org/sqlite/AllTests.java
rm -r src/test/java/org/sqlite/TransactionTest.java
sed -i '/TransactionTest/d' src/test/java/org/sqlite/AllTests.java
%ifarch %{power64}
rm -r src/test/java/org/sqlite/SQLiteDataSourceTest.java
sed -i '/SQLiteDataSourceTest/d' src/test/java/org/sqlite/AllTests.java
%endif
%patch0 -p1
%pom_add_plugin org.apache.maven.plugins:maven-antrun-plugin:1.7 . '
<dependencies>
 <dependency>
  <groupId>com.sun</groupId>
  <artifactId>tools</artifactId>
  <version>1.8.0</version>
 </dependency>
</dependencies>
<executions>
  <execution>
  <id>compile</id>
  <phase>process-classes</phase>
    <configuration>
      <target>
       <javac destdir="lib"
         srcdir="lib"
         source="1.6" target="1.6" debug="on"
         classpathref="maven.plugin.classpath">
         <include name="**/OSInfo.java"/>
       </javac>
       <exec executable="make">
        <arg line="%{?_smp_mflags}
        JAVA_HOME=%{_jvmdir}/java
        JAVA=%{_jvmdir}/java/bin/java
        JAVAC=%{_jvmdir}/java/bin/javac
        JAVAH=%{_jvmdir}/java/bin/javah
        native"/>
       </exec>
      </target>
    </configuration>
    <goals>
      <goal>run</goal>
    </goals>
  </execution>
</executions>'
cp -p src/main/java/org/sqlite/util/OSInfo.java lib/org/sqlite/
sed -i "s|package org.sqlite.util;|package org.sqlite;|" lib/org/sqlite/OSInfo.java
%mvn_file org.xerial:%{name} %{name}

%build
%ifarch %{arm}
opts='-f'
%endif
sed -i 's|$(CCFLAGS) -I|$(CCFLAGS) $(CFLAGS) -I|' Makefile
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ;
sed -i 's|$(CCFLAGS) -o|$(CCFLAGS) $(LDFLAGS) -o|' Makefile
LDFLAGS="${LDFLAGS:-%__global_ldflags}"; export LDFLAGS;
%mvn_build $opts -- -Dmaven.test.failure.ignore=true

%install
%mvn_install

%files -f .mfiles
%doc CHANGELOG README.md Usage.md
%license LICENSE* NOTICE

%files javadoc -f .mfiles-javadoc
%license LICENSE* NOTICE

%changelog
* Mon Aug 3 2020 Jeffery.Gao <gaojianxing@huawei.com> - 3.15.1-1
- Package init
