%global reltag .v20160428-59c81c5
%global namedversion %{version}%{?reltag}
%global core org.eclipse.persistence.core
%global dbws org.eclipse.persistence.dbws
%global extension org.eclipse.persistence.extension
%global jpa org.eclipse.persistence.jpa
%global jpql org.eclipse.persistence.jpa.jpql
%global modelgen org.eclipse.persistence.jpa.modelgen.processor
%global moxy org.eclipse.persistence.moxy
%global sdo org.eclipse.persistence.sdo
Name:                eclipselink
Version:             2.6.3
Release:             3
Summary:             Eclipse Persistence Services Project
License:             EPL-1.0 and BSD-3-Clause
Url:                 http://www.eclipse.org/eclipselink/
Source0:             http://www.mirrorservice.org/sites/download.eclipse.org/eclipseMirror/rt/%{name}/releases/%{version}/%{name}-src-%{namedversion}.zip
Source1:             %{name}-%{version}-build.properties
Source2:             %{name}-%{version}-build.xml
Source3:             https://repo1.maven.org/maven2/org/eclipse/persistence/%{name}/%{version}/%{name}-%{version}.pom
Source4:             https://repo1.maven.org/maven2/org/eclipse/persistence/%{core}/%{version}/%{core}-%{version}.pom
Source5:             https://repo1.maven.org/maven2/org/eclipse/persistence/%{dbws}/%{version}/%{dbws}-%{version}.pom
Source6:             https://repo1.maven.org/maven2/org/eclipse/persistence/%{extension}/%{version}/%{extension}-%{version}.pom
Source7:             https://repo1.maven.org/maven2/org/eclipse/persistence/%{jpa}/%{version}/%{jpa}-%{version}.pom
Source8:             https://repo1.maven.org/maven2/org/eclipse/persistence/%{jpql}/%{version}/%{jpql}-%{version}.pom
Source9:             https://repo1.maven.org/maven2/org/eclipse/persistence/%{modelgen}/%{version}/%{modelgen}-%{version}.pom
Source10:            https://repo1.maven.org/maven2/org/eclipse/persistence/%{moxy}/%{version}/%{moxy}-%{version}.pom
Source11:            https://repo1.maven.org/maven2/org/eclipse/persistence/%{sdo}/%{version}/%{sdo}-%{version}.pom
BuildRequires:       ant antlr3-java antlr3-tool aqute-bnd bean-validation-api cdi-api
BuildRequires:       eclipse-equinox-osgi eclipselink-persistence-api glassfish-jaxb-api
BuildRequires:       glassfish-jaxb-codemodel glassfish-jaxb-core glassfish-jaxb-jxc
BuildRequires:       glassfish-servlet-api java-devel java-javadoc javamail javapackages-local
BuildRequires:       jboss-connector-1.7-api jboss-jaxrs-2.0-api jboss-jms-2.0-api
BuildRequires:       jboss-transaction-1.2-api jgroups jsonp objectweb-asm stringtemplate4
BuildRequires:       tuscany-sdo-java xsom
BuildArch:           noarch
%description
Eclipse Persistence Services Project, more commonly known as EclipseLink,
is a Java comprehensive persistence framework delivering a set of persistence
services based around standards. This lets you rapidly build applications
that combine the best aspects of object technology and the specific data
source.
EclipseLink was started by a donation of the full source code and
test suites of Oracle's TopLink product.
EclipseLink's services currently include object-relational with JPA,
object-XML binding in MOXy (with support for JAXB), a Service Data Objects
(SDO) implementation and support for another technologies like: Database Web
Services (DWS), XML-Relational (XRM) and Non-Relational (EIS via JCA).

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

%prep
%setup -q -c
rm -r org/eclipse/persistence/internal/libraries/*
find ./ -name "*.java" -exec sed -i "s/org.eclipse.persistence.internal.libraries.antlr/org.antlr/g" {} +
find ./ -name "*.java" -exec sed -i "s/org.eclipse.persistence.internal.libraries.asm/org.objectweb.asm/g" {} +
sed -i "s|Token.EOF_TOKEN|Token.EOF|" \
 org/eclipse/persistence/internal/jpa/parsing/jpql/JPQLParser.java
cp -p %{SOURCE1} build.properties
cp -p %{SOURCE2} build.xml
cp -p %{SOURCE3} pom.xml
%pom_change_dep org.eclipse.persistence:commonj.sdo org.apache.tuscany.sdo:tuscany-sdo-api-r2.1:1.1.1
cp -p %{SOURCE4} core-pom.xml
%pom_change_dep org.eclipse.persistence:org.eclipse.persistence.asm org.ow2.asm:asm:5.0.4 core-pom.xml
%pom_add_dep org.ow2.asm:asm-commons:5.0.4:compile core-pom.xml
%pom_add_dep org.ow2.asm:asm-tree:5.0.4:compile core-pom.xml
%pom_add_dep org.ow2.asm:asm-tree:5.0.4:compile core-pom.xml
%pom_add_dep org.ow2.asm:asm-util:5.0.4:compile core-pom.xml
cp -p %{SOURCE7} jpa-pom.xml
%pom_change_dep org.eclipse.persistence:org.eclipse.persistence.antlr org.antlr:antlr-runtime:3.5.2 jpa-pom.xml
%pom_change_dep org.eclipse.persistence:org.eclipse.persistence.asm org.ow2.asm:asm:5.0.4 jpa-pom.xml
%pom_add_dep org.ow2.asm:asm:5.0.4:compile jpa-pom.xml
%pom_add_dep org.ow2.asm:asm-commons:5.0.4:compile jpa-pom.xml
%pom_add_dep org.ow2.asm:asm-tree:5.0.4:compile jpa-pom.xml
%pom_add_dep org.ow2.asm:asm-tree:5.0.4:compile jpa-pom.xml
%pom_add_dep org.ow2.asm:asm-util:5.0.4:compile jpa-pom.xml
cp -p %{SOURCE11} sdo-pom.xml
%pom_change_dep org.eclipse.persistence:commonj.sdo org.apache.tuscany.sdo:tuscany-sdo-api-r2.1:1.1.1 sdo-pom.xml
for s in org/eclipse/persistence/internal/jpa/transaction/JTATransactionWrapper.java \
  org/eclipse/persistence/jpa/jpql/parser/AbstractExpression.java \
  org/eclipse/persistence/jpa/jpql/tools/DefaultGrammarValidator.java \
  org/eclipse/persistence/jpa/jpql/tools/model/IScalarExpressionStateObjectBuilder.java \
  org/eclipse/persistence/platform/database/HANAPlatform.java \
  org/eclipse/persistence/platform/database/MaxDBPlatform.java;do
  native2ascii -encoding UTF8 ${s} ${s}
done

%build
%if "%{_arch}" == "riscv64"
export JAVA_TOOL_OPTIONS="-Xmx4096m"
%endif
(
 cd org/eclipse/persistence/internal/oxm/record/json/
 antlr3 JSON.g
)
(
 cd org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/
 sed -i '/Object node = null;/d' JPQL.g
 antlr3 JPQL.g
)
ant

%install
%mvn_artifact pom.xml target/%{name}.jar
%mvn_artifact core-pom.xml target/%{core}-%{version}.jar
%mvn_artifact %{SOURCE5} target/%{dbws}-%{version}.jar
%mvn_artifact %{SOURCE6} target/%{extension}-%{version}.jar
%mvn_artifact jpa-pom.xml target/%{jpa}-%{version}.jar
%mvn_artifact %{SOURCE8} target/%{jpql}-%{version}.jar
%mvn_artifact %{SOURCE9} target/%{modelgen}-%{version}.jar
%mvn_artifact %{SOURCE10} target/%{moxy}-%{version}.jar
%mvn_artifact sdo-pom.xml target/%{sdo}-%{version}.jar
%mvn_install -J target/api

%files -f .mfiles
%doc about.html readme.html
%license license.html

%files javadoc -f .mfiles-javadoc
%license license.html

%changelog
* Fri Jul 19 2024 yaoxin <yao_xin001@hoperun.com> - 2.6.3-3
- License compliance rectification

* Wed Apr 10 2024 Dingli Zhang <dingli@iscas.ac.cn> - 2.6.3-2
- Add -Xmx4096m for riscv64

* Tue Aug 4 2020 chengzihan <chengzihan2@huawei.com> - 2.6.3-1
- Package init
