Name:          glassfish-toplink-essentials
Version:       2.0.46
Release:       2
Summary:       Glassfish JPA Toplink Essentials
License:       CDDL or GPLv2 with exceptions
URL:           http://glassfish.java.net/javaee5/persistence/
Source0:       https://repo1.maven.org/maven2/toplink/essentials/toplink-essentials/2.0-46/toplink-essentials-2.0-46-sources.jar
Source1:       https://repo1.maven.org/maven2/toplink/essentials/toplink-essentials/2.0-46/toplink-essentials-2.0-46.pom
Source2:       https://repo1.maven.org/maven2/toplink/essentials/toplink-essentials-agent/2.0-46/toplink-essentials-agent-2.0-46.pom
Source3:       https://javaee.github.io/glassfish/LICENSE
Patch0:        0001-fix-toplink-essentials-pom.patch
Patch1:        glassfish-persistence-2.0.41-jdk7.patch
Patch2:        glassfish-persistence-2.0.41-use_system_antlr.patch
BuildRequires: java-devel jpackage-utils javapackages-local maven-local ant antlr-tool geronimo-jta geronimo-jpa
BuildRequires: mvn(org.apache.maven.plugins:maven-javadoc-plugin)
BuildRequires: mvn(org.jboss.spec.javax.resource:jboss-connector-api_1.6_spec)
BuildRequires: mvn(org.jboss.spec.javax.jms:jboss-jms-api_1.1_spec)
BuildRequires: mvn(org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec)
BuildRequires: mvn(org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec)
BuildRequires: mvn(javax.jdo:jdo2-api)
Requires:      antlr-tool geronimo-jpa geronimo-jta jpackage-utils
BuildArch:     noarch

%description
Glassfish Persistence Implementation.

%package javadoc
Summary:       Javadoc for %{name} Implementation

%description javadoc
This package contains javadoc for %{name}.

%prep
%setup -q -c 
mkdir -p src/main/java
mv javax src/main/java
mv oracle src/main/java
mv persistence src/main/java
cp %{SOURCE1} .
cp %{SOURCE2} .
cp %{SOURCE3} ./LICENSE.html
%patch0 -p1
%patch1 -p1
%patch2 -p1
cp ./toplink-essentials-2.0-46.pom ./pom.xml
rm -rf src/main/java/persistence/antlr/

%build
%mvn_build -- -Dproject.build.sourceEncoding=UTF-8
rm -f pom.xml
pushd src/main/java/oracle/toplink/essentials/internal/ejb/cmp3/
ls | grep -v "JavaSECMPInitializerAgent.java" | xargs rm -rf
popd
cp ./toplink-essentials-agent-2.0-46.pom ./pom.xml
%mvn_build -- -Dproject.build.sourceEncoding=UTF-8

%install
mkdir -p %{buildroot}%{_javadir}/glassfish
install -m 644 target/toplink-essentials-2.0.46.jar %{buildroot}%{_javadir}/%{name}.jar
install -m 644 target/toplink-essentials-agent-2.0-46.jar %{buildroot}%{_javadir}/%{name}-agent.jar

mkdir -p %{buildroot}%{_mavenpomdir}
install -pm 644 ./toplink-essentials-2.0-46.pom %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
%add_maven_depmap JPP-%{name}.pom %{name}.jar
install -pm 644 ./toplink-essentials-agent-2.0-46.pom %{buildroot}%{_mavenpomdir}/JPP-%{name}-agent.pom
%add_maven_depmap JPP-%{name}-agent.pom %{name}-agent.jar

mkdir -p %{buildroot}%{_javadocdir}/%{name}
cp -pr target/site/apidocs/* %{buildroot}%{_javadocdir}/%{name}

%files -f .mfiles
%license ./LICENSE.html

%files javadoc
%{_javadocdir}/%{name}
%license ./LICENSE.html

%changelog
* Tue Oct 20 2020 Ge Wang <wangge20huawei.com> - 2.0.46-2
- modify compile script to solve defect of jar package

* Thu Aug 27 2020 Ge Wang <wangge20@huawei.com> - 2.0.46-1
- package init

