Name:          rhino
Version:       1.7.7.1
Release:       8
Summary:       Open-source implementation of JavaScript written entirely in Java
License:       MPLv2.0
URL:           http://www.mozilla.org/rhino/
Source0:       https://github.com/mozilla/rhino/archive/Rhino1_7_7_1_RELEASE.tar.gz
Source1:       https://repo1.maven.org/maven2/org/mozilla/rhino/%{version}/rhino-%{version}.pom
Source2:       %{name}.script
Patch0:        %{name}-build.patch
Patch1:        %{name}-addOrbitManifest.patch
BuildArch:     noarch

BuildRequires: ant, java-devel >= 1:1.6.0.0, sonatype-oss-parent, javapackages-local
Requires:      jline, javapackages-tools
Provides:      %{name}-demo%{?_isa} %{name}-demo
Obsoletes:     %{name}-demo
Obsoletes:     %{name}-javadoc < %{version}-%{release}
Obsoletes:     %{name}-manual < %{version}-%{release}

%description
Rhino is an open-source implementation of JavaScript written entirely in Java.
It is typically embedded into Java applications to provide scripting to end users.
It is embedded in J2SE 6 as the default Java scripting engine.

%package        help
Summary:        man files for %{name}
Requires:       man

%description    help
This package includes man files for %{name}.

%prep
%setup -q -n %{name}-Rhino1_7_7_1_RELEASE
%patch0 -p1 -b .build
%patch1 -b .fixManifest

sed -i -e '/^Class-Path:.*$/d' src/manifest
sed -i -e 's|^implementation.version: Rhino .* release .* \${implementation.date}|implementation.version: Rhino %{version} release %{release} \${implementation.date}|' build.properties

%mvn_alias : rhino:js
%mvn_file : js %{name}

%build
ant deepclean jar copy-all -Dno-xmlbeans=1
%mvn_artifact %{SOURCE1} build/%{name}%{version}/js.jar

cd examples
export CLASSPATH=../build/%{name}%{version}/js.jar:$(build-classpath xmlbeans/xbean 2>/dev/null)
%{javac} *.java
%{jar} cf ../build/%{name}%{version}/%{name}-examples.jar *.class
cd -

%install
%mvn_install

install -d $RPM_BUILD_ROOT%{_mandir}/man1/
install -m 644 man/%{name}.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{name}.1

install -d $RPM_BUILD_ROOT%{_bindir}
install -m 755 %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}/%{name}

cp -a build/%{name}%{version}/%{name}-examples.jar $RPM_BUILD_ROOT%{_javadir}/%{name}-examples.jar
install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -a examples/* $RPM_BUILD_ROOT%{_datadir}/%{name}
find $RPM_BUILD_ROOT%{_datadir}/%{name} -name '*.build' -delete

%files -f .mfiles
%attr(0755,root,root) %{_bindir}/*
%{_javadir}/*
%{_datadir}/%{name}

%files help
%{_mandir}/man*/*

%changelog
* Wed Nov 9 2022 liyanan <liyanan32@h-partners.com> - 1.7.7.1-8
- Change source

* Wed Dec 4 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.7.7.1-7
- Package init
