Name:          jakarta-commons-httpclient
Version:       3.1
Release:       30
Epoch:         1
Summary:       Implement the client side of HTTP standards
License:       ASL 2.0 and (ASL 2.0 or LGPLv2+)
URL:           http://jakarta.apache.org/commons/httpclient/
Source0:       http://archive.apache.org/dist/httpcomponents/commons-httpclient/source/commons-httpclient-3.1-src.tar.gz
Source1:       http://repo.maven.apache.org/maven2/commons-httpclient/commons-httpclient/%{version}/commons-httpclient-%{version}.pom
Patch0:        %{name}-disablecryptotests.patch
Patch1:        %{name}-addosgimanifest.patch
Patch2:        %{name}-encoding.patch
Patch3:        %{name}-CVE-2012-5783.patch
Patch4:        %{name}-CVE-2014-3577.patch
Patch5:        %{name}-CVE-2015-5262.patch
BuildArch:     noarch

BuildRequires: maven-local, ant, apache-commons-codec, apache-commons-logging >= 0:1.0.3
BuildRequires: apache-commons-logging-javadoc, java-javadoc, junit
Requires:      java-headless, apache-commons-logging >= 0:1.0.3, apache-commons-codec
Provides:      %{name}-javadoc%{?_isa} %{name}-javadoc
Obsoletes:     %{name}-javadoc
Provides:      %{name}-demo%{?_isa} %{name}-demo
Obsoletes:     %{name}-demo
Provides:      %{name}-manual%{?_isa} %{name}-manual
Obsoletes:     %{name}-manual

%description
The Hyper-Text Transfer Protocol (HTTP) is perhaps the most significant protocol used on the Internet today.
Web services, network-enabled appliances and the growth of network computing continue to expand the role of
the HTTP protocol beyond user-driven web browsers, while increasing the number of applications that require
HTTP support.
Designed for extension while providing robust support for the base HTTP protocol, the HttpComponents may be
of interest to anyone building HTTP-aware client and server applications such as web browsers, web spiders,
HTTP proxies, web service transport libraries, or systems that leverage or extend the HTTP protocol for
distributed communication.

%prep
%setup -q -n commons-httpclient-%{version}
install -d lib
build-jar-repository -p lib commons-codec commons-logging junit
rm -rf docs/apidocs docs/*.patch docs/*.orig docs/*.rej

%patch0

cd src/conf
%{__sed} -i 's/\r//' MANIFEST.MF
%patch1
cd -

%patch2
%patch3 -p2
%patch4 -p1
%patch5 -p1

cd src
    for j in $(find . -name "*.java" -exec grep -l 'com\.sun\.net\.ssl' {} \;); do
        sed -e 's|com\.sun\.net\.ssl|javax.net.ssl|' $j > tempf
        cp tempf $j
    done
    rm tempf
cd -

%mvn_alias : apache:commons-httpclient
%mvn_file ":{*}" jakarta-@1 "@1" commons-httpclient3

%build
ant -Dbuild.sysclasspath=first -Djavadoc.j2sdk.link=%{_javadocdir}/java -Djavadoc.logging.link=%{_javadocdir}/jakarta-commons-logging \
  -Dtest.failonerror=false -Djavac.encoding=UTF-8 dist test

%install
%mvn_artifact %{SOURCE1} dist/commons-httpclient.jar
%mvn_install -J dist/docs/api

install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -pr src/examples src/contrib $RPM_BUILD_ROOT%{_datadir}/%{name}

rm -Rf dist/docs/{api,BUILDING.txt,TESTING.txt}
ln -s %{_javadocdir}/%{name} dist/docs/apidocs

%files -f .mfiles
%doc NOTICE README RELEASE_NOTES dist/docs/*
%license LICENSE
%{_javadocdir}/%{name}/*
%{_datadir}/%{name}

%changelog
* Mon Dec 9 2019 openEuler Buildteam <buildteam@openeuler.org> - 1:3.1-30
- Package init
