Summary:             High-performance, full-featured text search engine
Name:                lucene3
Version:             3.6.2
Release:             1
Epoch:               0
License:             ASL 2.0 and BSD
URL:                 http://lucene.apache.org/
Source0:             https://archive.apache.org/dist/lucene/java/%{version}/lucene-%{version}-src.tgz
Source1:             lucene-%{version}-core-OSGi-MANIFEST.MF
Source2:             lucene-%{version}-analysis-OSGi-MANIFEST.MF
Patch0:              lucene_contrib_icu4j_v50.patch
Patch1:              lucene-3.6.2-hamcrest-core.patch
Patch2:              lucene-3.6.2-javascript.patch
Patch3:              test-framework.patch
#svn export http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_6_2/dev-tools@r145
#tar caf dev-tools.tar.xz dev-tools/
Source4:             dev-tools.tar.xz
BuildRequires:       ant ant-junit apache-commons-codec apache-commons-compress
BuildRequires:       apache-commons-digester apache-ivy apache-parent hamcrest-core icu4j ivy-local
BuildRequires:       javacc java-javadoc jtidy junit lucene3 regexp xerces-j2 subversion
BuildArch:           noarch
%description
Apache Lucene is a high-performance, full-featured text search
engine library written entirely in Java. It is a technology suitable
for nearly any application that requires full-text search, especially
cross-platform.

%package contrib
Summary:             Lucene contributed extensions
Requires:            %{name} = %{epoch}:%{version}-%{release}
%description contrib
%{summary}.

%package javadoc
Summary:             Javadoc for Lucene
%description javadoc
%{summary}.

%prep
%setup -q -n lucene-%{version}
find . -name "*.jar" -delete
tar xfs %{SOURCE4}
pushd dev-tools
find . -name "pom.xml.template" -exec sed -i "s/@version@/%{version}/g" '{}' \;
popd
iconv --from=ISO-8859-1 --to=UTF-8 CHANGES.txt > CHANGES.txt.new
find . -name '*pom.xml.template' -exec \
              sed -i "s:@version@:%{version}:g" '{}' \;
sed -i -e "s|3.5.0|3.6.2|g" backwards/ivy.xml
%patch0 -p2
%patch1 -p1
%patch2 -p1
%patch3 -p0

%build
mkdir -p docs
mkdir -p lib
export OPT_JAR_LIST="ant/ant-junit junit hamcrest/core"
export CLASSPATH=$(build-classpath jtidy regexp commons-codec commons-digester commons-compress icu4j ivy xmvn)
ant -Divy.mode=local -Dbuild.sysclasspath=first \
  -Djavacc.home=%{_bindir}/javacc \
  -Djavacc.jar=%{_javadir}/javacc.jar \
  -Djavacc.jar.dir=%{_javadir} \
  -Djavadoc.link=file://%{_javadocdir}/java \
  -Dversion=%{version} \
  -Dfailonjavadocwarning=false \
  -Dmaven-tasks.uptodate=true \
  -Djavac.source=1.6 \
  -Djavac.target=1.6 \
  -Djavac.source.backwards=1.6 \
  -Djavac.target.backwards=1.6 \
  jar-lucene-core jar-test-framework docs javadocs build-contrib
mkdir META-INF
unzip -o build/core/lucene-core-%{version}.jar META-INF/MANIFEST.MF
cp %{SOURCE1} META-INF/MANIFEST.MF
sed -i '/^\r$/d' META-INF/MANIFEST.MF
zip build/core/lucene-core-%{version}.jar META-INF/MANIFEST.MF
unzip -o build/contrib/analyzers/common/lucene-analyzers-%{version}.jar META-INF/MANIFEST.MF
cp %{SOURCE2} META-INF/MANIFEST.MF
sed -i '/^\r$/d' META-INF/MANIFEST.MF
zip build/contrib/analyzers/common/lucene-analyzers-%{version}.jar META-INF/MANIFEST.MF
mv build/contrib/analyzers/common build/contrib/analyzers/analyzers
mv dev-tools/maven/lucene/contrib/analyzers/common dev-tools/maven/lucene/contrib/analyzers/analyzers
sed -i -e '/relativePath/d' dev-tools/maven/pom.xml.template
%mvn_artifact dev-tools/maven/pom.xml.template
%mvn_artifact dev-tools/maven/lucene/pom.xml.template
%mvn_artifact dev-tools/maven/lucene/core/pom.xml.template build/core/lucene-core-%{version}.jar
%mvn_artifact dev-tools/maven/lucene/contrib/pom.xml.template
%mvn_package :lucene-contrib-aggregator contrib
for c in benchmark demo facet grouping highlighter icu instantiated join \
         memory misc pruning queries queryparser remote spatial spellchecker xml-query-parser ; do
  %mvn_artifact dev-tools/maven/lucene/contrib/$c/pom.xml.template build/contrib/$c/lucene-${c}-%{version}.jar
  %mvn_package :lucene-${c} contrib
done
for c in analyzers kuromoji phonetic smartcn stempel ; do
  %mvn_artifact dev-tools/maven/lucene/contrib/analyzers/$c/pom.xml.template build/contrib/analyzers/$c/lucene-${c}-%{version}.jar
  %mvn_package :lucene-${c} contrib
done
%mvn_compat_version : 3 3.6.2

%install
%mvn_install -J build/docs/api

%files -f .mfiles
%doc CHANGES.txt README.txt
%license LICENSE.txt NOTICE.txt

%files javadoc -f .mfiles-javadoc
%license LICENSE.txt NOTICE.txt

%files contrib -f .mfiles-contrib
%doc contrib/CHANGES.txt
%license LICENSE.txt NOTICE.txt

%changelog
* Sat Aug 22 2020 Jeffery.Gao <gaojianxing@huawei.com> - 3.6.2-1
- package init
