Name:           hamcrest
Version:        1.3
Release:        25
Epoch:          0
Summary:        Library of matcher objects for building test expressions

License:        BSD
URL:            https://github.com/hamcrest/JavaHamcrest
Source0:        https://github.com/hamcrest/JavaHamcrest/archive/hamcrest-java-%{version}.tar.gz
Source1:        hamcrest-core-MANIFEST.MF
Source2:        hamcrest-library-MANIFEST.MF
Source3:        hamcrest-integration-MANIFEST.MF
Source4:        hamcrest-generator-MANIFEST.MF

Patch0001:      hamcrest-1.3-build.patch
Patch0002:      hamcrest-1.3-no-jarjar.patch
Patch0003:      hamcrest-1.3-javadoc.patch
Patch0004:      hamcrest-1.3-qdox-2.0.patch
Patch0005:      hamcrest-1.3-fork-javac.patch

# pacth for openEuler
Patch9000:      getMethods-sort.patch

BuildArch:      noarch
BuildRequires:  javapackages-local ant ant-junit easymock junit qdox testng
Requires:       qdox easymock >= 3.0

Provides:       %{name}-core = %{epoch}:%{version}-%{release}
Obsoletes:      %{name}-core < %{epoch}:%{version}-%{release}

%description
Provides a library of matcher objects (also known as constraints or
predicates) allowing 'match' rules to be defined declaratively, to be
used in other frameworks. Typical scenarios include testing frameworks,
mocking libraries and UI validation rules.

%package help
Summary:        Javadoc for hamcrest package
Provides:       %{name}-javadoc = %{epoch}:%{version}-%{release}
Obsoletes:      %{name}-javadoc < %{epoch}:%{version}-%{release}

%description help
Javadoc for hamcrest package.

%package demo
Summary:        Demos for hamcrest package
Requires:       junit testng %{name} = %{epoch}:%{version}-%{release}

%description demo
Demo files for hamcrest package.

%prep
%autosetup -n JavaHamcrest-%{name}-java-%{version} -p1

find . -type f -name "*.jar" -delete
rm -rf hamcrest-integration/src/main/java/org/hamcrest/integration/JMock1Adapter.java
rm -rf hamcrest-integration/src/main/java/org/hamcrest/JMock1Matchers.java
rm -rf hamcrest-unit-test/src/main/java/org/hamcrest/integration/JMock1AdapterTest.java


ln -sf $(build-classpath qdox) lib/generator/
ln -sf $(build-classpath easymock3) lib/integration/
ln -sf $(build-classpath jmock) lib/integration/
ln -sf $(build-classpath testng-jdk15) lib/integration/

%build
export CLASSPATH=$(build-classpath qdox)
export OPT_JAR_LIST="junit ant/ant-junit"
ant -Dant.build.javac.source=1.5 -Dversion=%{version} -Dbuild.sysclasspath=last clean core generator library bigjar javadoc

jar ufm build/hamcrest-core-%{version}.jar %{SOURCE1}
jar ufm build/hamcrest-library-%{version}.jar %{SOURCE2}
jar ufm build/hamcrest-integration-%{version}.jar %{SOURCE3}
jar ufm build/hamcrest-generator-%{version}.jar %{SOURCE4}

%install
sed -i 's/@VERSION@/%{version}/g' pom/*.pom

%mvn_artifact pom/hamcrest-parent.pom
%mvn_artifact pom/hamcrest-all.pom build/hamcrest-all-%{version}.jar
%mvn_artifact pom/hamcrest-core.pom build/hamcrest-core-%{version}.jar
%mvn_artifact pom/hamcrest-generator.pom build/hamcrest-generator-%{version}.jar
%mvn_artifact pom/hamcrest-library.pom build/hamcrest-library-%{version}.jar
%mvn_artifact pom/hamcrest-integration.pom build/hamcrest-integration-%{version}.jar

%mvn_package :hamcrest-parent core
%mvn_package :hamcrest-core core

%mvn_file ':hamcrest-{*}' %{name}/@1

install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/hamcrest
cp -rp hamcrest-examples $RPM_BUILD_ROOT%{_datadir}/hamcrest/

%mvn_install -J build/temp/hamcrest-all-1.3-javadoc.jar.contents/


%files -f .mfiles -f .mfiles-core
%license LICENSE.txt

%files help -f .mfiles-javadoc

%files demo
%{_datadir}/hamcrest

%changelog
* Tue Dec 03 2019 daiqianwen <daiqianwen@huawei.com> - 0:1.3-25
- Package init

