%bcond_without buildtex
%global jarname   rabbitmq-client
%global failjava  true
%global failjunit no
Name:                rabbitmq-java-client
Version:             3.6.5
Release:             3
Summary:             Java Advanced Message Queue Protocol client library
License:             ASL 2.0 and GPLv2+ and MPLv1.1
URL:                 http://www.rabbitmq.com/java-client.html
Source0:             http://www.rabbitmq.com/releases/%{name}/v%{version}/%{name}-%{version}.tar.gz
BuildArch:           noarch
BuildRequires:       maven-local mvn(commons-cli:commons-cli) mvn(commons-io:commons-io) mvn(junit:junit)
BuildRequires:       ant ant-junit java-headless python3-devel >= 2.6 python3-simplejson
%if 0%{?with buildtex}
BuildRequires:       texi2html texlive-base
%endif
BuildRequires:       rabbitmq-server hostname procps-ng
Suggests:            rabbitmq-server
Suggests:            activemq
%description
The library allows Java code to interface to AMQP servers.
Please see the specification page for more information on AMQP
inter-operation and standards-conformance
You will need an AMQP server, such as our very own RabbitMQ server,
to use with the client library.

%package doc
Summary:             Documentation for %{name}
Requires:            %{name} = %{version}-%{release}
%description doc
This package contains additional documentation for %{name}.

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

%prep
%setup -q
find . -name "*.bat" -delete
find . -name "*.class" -delete
find . -name "*.jar" -print -delete
rm Makefile
ln -sf $(build-classpath commons-cli) lib/
ln -sf $(build-classpath commons-io) lib/
ln -sf $(build-classpath junit) lib/
sed -i "s|, bundlor.do||" build.xml
sed -i "s|, test-bundlor.do||" build.xml
sed -i 's,\(\"haltOnFailureJunit\" value=\"\).*\",\1%{failjunit}\",' build.xml
sed -i 's,\(\"haltOnFailureJava\" value=\"\).*\",\1%{failjava}\",' build.xml
%mvn_file com.rabbitmq:amqp-client %{name} %{jarname} amqp-client

%build
%ant -Dimpl.version=%{version} -Dpython.bin=%{__python3} maven-bundle
cd doc/channels
%if 0%{?with buildtex}
find . -name \*.tex -print -exec 'texi2html {} ; pdflatex {}' \; -delete
%endif
find . -not -name channels.\* -delete

%install
%mvn_artifact build/bundle/amqp-client-%{version}.pom build/bundle/amqp-client-%{version}.jar
%mvn_install -J build/doc/api

%check
ant test-jar
ant test-server
export RABBITMQ_LOG_BASE=.
export RABBITMQ_MNESIA_BASE=.
%{_prefix}/lib/rabbitmq/bin/rabbitmq-server start -detached
pgrep -cf rabbitmq_server && ant test-client
pkill -f rabbitmq_server ||:

%clean
sleep 150

%files -f .mfiles
%license LICENSE*
%doc README*

%files doc
%doc doc/*

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

%changelog
* Fri Jul 07 2023 Ge Wang <wang__ge@126.com> - 3.6.5-3
- Fix build failure caused by deletion failed in rmbuid stage

* Tue Oct 27 2020 Anan Fu <fuanan3@huawei.com> - 3.6.5-2
- disable python2 module

* Wed Aug 26 2020 shaoqiang kang <kangshaoqiang1@huawei.com> - 3.6.5-1
- Package init
