%global commit e02f7c887d666afbdd11763f3a6ba22e68f53f15
%global shortcommit %(c=%{commit}; echo ${c:0:7})

%bcond_with hadoop

Name:           dain-snappy
Version:        0.4
Release:        7
Summary:        Port of Snappy to Java
License:        ASL 2.0 and BSD
URL:            https://github.com/dain/snappy

Source0:        https://github.com/dain/snappy/archive/%{commit}/%{name}-%{shortcommit}.tar.gz

BuildArch:      noarch
BuildRequires:  maven-local guava maven-enforcer-plugin maven-source-plugin testng snappy-java

%if %{with hadoop}
BuildRequires:  hadoop-common
%endif
Provides:       %{name}-javadoc = %{version}-%{release}
Obsoletes:      %{name}-javadoc < %{version}-%{release}

%description
This is a rewrite (port) of Snappy writen in pure Java. This compression code produces a 
byte-for-byte exact copy of the output created by the original C++ code, and extremely fast.

%prep
%autosetup -n snappy-%{commit}
%pom_remove_plugin :maven-javadoc-plugin
%pom_remove_plugin :maven-surefire-plugin
%pom_remove_plugin :really-executable-jar-maven-plugin

%if %{with hadoop}
%pom_change_dep :hadoop-core :hadoop-common
%else
%pom_remove_dep :hadoop-core
find -name HadoopSnappyCodec.java | xargs rm -f
find -name TestHadoopSnappyCodec.java | xargs rm -f
%endif

sed -i /@Test/d $(find -name SnappyTest.java)

%build
%mvn_build

%install
%mvn_install

%files
%defattr(-,root,root)
%doc README.md notice.md
%license license.txt
%{_datadir}/java/*
%{_datadir}/javadoc/*
%{_datadir}/maven-poms/*
%{_datadir}/maven-metadata/*

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