%global with_tests 0
Name:                openjpa
Version:             2.4.1
Release:             2
Summary:             Java Persistence 2.0 API
License:             ASL 2.0 and CDDL
Url:                 http://openjpa.apache.org/
Source0:             http://archive.apache.org/dist/openjpa/%{version}/%{name}-parent-%{version}-source-release.zip
Patch0:              %{name}-2.3.0-remove-WASRegistryManagedRuntime.patch
Patch1:              openjpa-2.4.1-javacc6.patch
BuildRequires:       maven-local mvn(ant-contrib:ant-contrib) mvn(com.sun.xml.bind:jaxb-impl)
BuildRequires:       mvn(commons-collections:commons-collections) mvn(commons-dbcp:commons-dbcp)
BuildRequires:       mvn(commons-lang:commons-lang) mvn(commons-logging:commons-logging)
BuildRequires:       mvn(commons-pool:commons-pool) mvn(hsqldb:hsqldb:1) mvn(httpunit:httpunit)
BuildRequires:       mvn(jakarta-regexp:jakarta-regexp) mvn(javax.servlet:javax.servlet-api)
BuildRequires:       mvn(javax.xml.bind:jaxb-api) mvn(junit:junit) mvn(log4j:log4j:1.2.17)
BuildRequires:       mvn(mysql:mysql-connector-java) mvn(net.sourceforge.serp:serp)
BuildRequires:       mvn(org.apache:apache:pom:) mvn(org.apache.ant:ant)
BuildRequires:       mvn(org.apache.ant:ant-jsch) mvn(org.apache.bval:bval-core)
BuildRequires:       mvn(org.apache.bval:bval-jsr303) mvn(org.apache.commons:commons-jci-rhino)
BuildRequires:       mvn(org.apache.derby:derby) mvn(org.apache.derby:derbyclient)
BuildRequires:       mvn(org.apache.geronimo.specs:geronimo-jms_1.1_spec)
BuildRequires:       mvn(org.apache.geronimo.specs:geronimo-jta_1.1_spec)
BuildRequires:       mvn(org.apache.geronimo.specs:geronimo-validation_1.0_spec)
BuildRequires:       mvn(org.apache.geronimo.specs:specs:pom:)
BuildRequires:       mvn(org.apache.maven:maven-plugin-api) mvn(org.apache.maven:maven-project)
BuildRequires:       mvn(org.apache.maven.plugin-testing:maven-plugin-testing-harness)
BuildRequires:       mvn(org.apache.maven.plugins:maven-antrun-plugin)
BuildRequires:       mvn(org.apache.maven.plugins:maven-dependency-plugin)
BuildRequires:       mvn(org.apache.maven.plugins:maven-enforcer-plugin)
BuildRequires:       mvn(org.apache.maven.plugins:maven-plugin-plugin)
BuildRequires:       mvn(org.apache.maven.plugins:maven-remote-resources-plugin)
BuildRequires:       mvn(org.apache.maven.plugins:maven-shade-plugin)
BuildRequires:       mvn(org.apache.maven.plugins:maven-site-plugin)
BuildRequires:       mvn(org.apache.xbean:xbean-finder)
BuildRequires:       mvn(org.codehaus.mojo:build-helper-maven-plugin)
BuildRequires:       mvn(org.codehaus.mojo:buildnumber-maven-plugin)
BuildRequires:       mvn(org.codehaus.mojo:javacc-maven-plugin)
BuildRequires:       mvn(org.codehaus.plexus:plexus-utils)
BuildRequires:       mvn(org.hibernate.javax.persistence:hibernate-jpa-2.0-api) mvn(org.jmock:jmock)
BuildRequires:       mvn(org.jmock:jmock-junit4) mvn(org.osgi:org.osgi.core) mvn(org.ow2.asm:asm)
BuildRequires:       mvn(org.slf4j:slf4j-api) mvn(postgresql:postgresql)
%if 0
BuildRequires:       mvn(mariadb:mariadb-connector-java)
%endif
BuildArch:           noarch
%description
OpenJPA is Apache's implementation of Sun's Java Persistence 2.0 API
(JSR-317 JPA 2.0) specification for the transparent persistence of
Java objects.
It is an object-relational mapping (ORM) solution for the Java language,
which simplifies storing objects in databases.

%package tools
Summary:             OpenJPA tools - Maven Plugin
%description tools
OpenJPA tasks for enhancing, SQL creation and
schema mapping creation using Apache maven.

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

%prep
%setup -q -n %{name}-parent-%{version}
find . -name "*.class" -delete
find . -name "*.jar" -delete
%patch0 -p0
%patch1 -p1
%pom_disable_module %{name}
%pom_disable_module %{name}-all
%pom_disable_module %{name}-examples
%pom_disable_module %{name}-integration
%pom_disable_module %{name}-project
%pom_disable_module openbooks %{name}-examples
%pom_remove_plugin :docbkx-maven-plugin
%pom_remove_plugin :maven-checkstyle-plugin
%pom_remove_plugin :findbugs-maven-plugin
%pom_remove_plugin :ianal-maven-plugin
%pom_remove_plugin :taglist-maven-plugin
%pom_remove_plugin :apache-rat-plugin
%pom_remove_dep net.sourceforge.findbugs:annotations
%pom_remove_dep simple-jndi:simple-jndi openjpa-persistence-jdbc 
%pom_xpath_remove "pom:profile[pom:id='ydoc-profile']"
%pom_xpath_remove "pom:profile[pom:id='test-sybase-jconnect']" %{name}-persistence-jdbc
%pom_xpath_remove "pom:profile[pom:id='test-soliddb']" %{name}-persistence-jdbc
for p in persistence-jdbc persistence-locking; do
%pom_xpath_remove "pom:profile[pom:id='test-custom']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-custom2']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-db2-jcc']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-derbyjcc']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-ids-jcc']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-ids-informix']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-ingres']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-mssql']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-oracle']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-sqlserver']" %{name}-${p}
%pom_xpath_remove "pom:profile[pom:id='test-sybase']" %{name}-${p}
done
%pom_change_dep -r :geronimo-jpa_2.0_spec org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final
%pom_remove_dep com.ibm.websphere:websphere_uow_api %{name}-kernel
rm %{name}-kernel/src/main/java/org/apache/openjpa/ee/WASRegistryManagedRuntime.java
%pom_xpath_set "pom:dependency[pom:groupId = 'org.apache.xbean']/pom:artifactId" xbean-finder %{name}-kernel
sed -i "s|org.apache.xbean.asm5|org.objectweb.asm|" \
 %{name}-kernel/src/main/java/org/apache/openjpa/enhance/AsmAdaptor.java
%pom_add_dep org.ow2.asm:asm:5.0.3 %{name}-kernel
%pom_change_dep -r :hsqldb ::1 %{name}-jdbc
%pom_xpath_set "pom:properties/pom:hsqldb.version" 1
%pom_change_dep -r log4j: ::1.2.17
%pom_remove_plugin :maven-invoker-plugin %{name}-tools/%{name}-maven-plugin
%pom_change_dep org.apache.bval: :bval-core:1.1.1
%pom_change_dep org.apache.bval: :bval-core:1.1.1 %{name}-tools/%{name}-maven-plugin
%pom_add_dep org.apache.bval:bval-jsr:1.1.1 %{name}-tools/%{name}-maven-plugin
%pom_change_dep javax.servlet:servlet-api :javax.servlet-api:3.1.0 %{name}-jest
%mvn_package ":%{name}-tools" tools
%mvn_package ":%{name}-maven-plugin" tools
%mvn_package ":%{name}-fetch-statistics" tools
%mvn_package ":%{name}-fetch-statistics-was" tools

%build
export MAVEN_OPTS="-Xms1024m -Xmx2048m -Xss5m"
%mvn_build -- \
%if %{with_tests}
  -Ptest-derby \
%else
  -Dtest=false \
%endif
  -DfailIfNoTests=false \
  -Dmaven.test.failure.ignore=true \
  process-resources

%install
%mvn_install
mkdir -p %{buildroot}%{_sysconfdir}/ant.d
echo "ant %{name}/%{name}-jdbc %{name}/%{name}-kernel %{name}/%{name}-lib" > %{name}-ant
install -p -m 644 %{name}-ant %{buildroot}%{_sysconfdir}/ant.d/%{name}

%files -f .mfiles
%config(noreplace) %{_sysconfdir}/ant.d/%{name}
%doc README.txt
%license LICENSE NOTICE

%files tools -f .mfiles-tools
%license LICENSE NOTICE

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

%changelog
* Tue Oct 27 2020 huanghaitao <huanghaitao8@huawei.com> - 2.4.1-2
- Remove simple-json dep

* Wed Aug 19 2020 zhanghua <zhanghua40@huawei.com> - 2.4.1-1
- Package init
