Summary:             High-performance, full-featured text search engine
Name:                lucene4
Version:             4.10.4
Release:             1
Epoch:               0
License:             ASL 2.0
URL:                 http://lucene.apache.org/
Source0:             http://archive.apache.org/dist/lucene/java/%{version}/lucene-%{version}-src.tgz
# svn export http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_4_10_4dev-tools/
# tar caf dev-tools-4.10.4.tar.xz dev-tools/
Source1:             dev-tools-%{version}.tar.xz
Patch0:              0001-disable-ivy-settings.patch
Patch1:              0001-dependency-generation.patch
Patch2:              lucene-4.10.4-morfologik-stemming.patch
Patch3:              0001-SOLR-11477-Disallow-resolving-of-external-entities-i.patch
Patch4:              RandomInts-oe.patch
Patch5:              spatial4j-oe.patch

BuildRequires:       git subversion ant ivy-local apache-ivy icu4j httpcomponents-client
BuildRequires:       jetty-continuation jetty-http jetty-io jetty-server jetty-servlet jetty-util
BuildRequires:       morfologik-stemming uimaj uima-addons spatial4j nekohtml xerces-j2
BuildRequires:       mvn(javax.servlet:javax.servlet-api) mvn(org.antlr:antlr-runtime) maven-local
BuildRequires:       apache-parent buildnumber-maven-plugin maven-plugin-bundle regexp
BuildRequires:       junit randomizedtesting-junit4-ant randomizedtesting-runner
Provides:            %{name}-core = %{epoch}:%{version}-%{release}
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 javadoc
Summary:             Javadoc for Lucene

%description javadoc
%{summary}.

%prep
%setup -q -n lucene-%{version}
mkdir lucene
find -maxdepth 1 \
    ! -name CHANGES.txt ! -name LICENSE.txt ! -name README.txt \
    ! -name NOTICE.txt ! -name MIGRATE.txt  ! -name ivy-settings.xml \
    ! -path ./lucene -exec mv \{} lucene/ \;
tar xf %{SOURCE1}
pushd lucene
%patch0 -p1
%patch1 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
find . -name "*.jar" -delete
rm sandbox/src/test/org/apache/lucene/sandbox/queries/regex/TestJakartaRegexpCapabilities.java
rm -r replicator/src/test/*
rm -r analysis/common/src/test/*
ln -s %{_sysconfdir}/ivy/ivysettings.xml
popd
%patch2 -p1
sed -i -e '/Export-Package/a<Import-Package>org.apache.lucene*;version="[${project.version},5.0.0)",org.tartarus*;version="[${project.version},5.0.0)",*</Import-Package>' \
  dev-tools/maven/pom.xml.template
%mvn_alias :lucene-suggest :lucene-spellchecker
%mvn_alias :lucene-analyzers-common :lucene-analyzers
%mvn_compat_version : 4 %{version}

%build
pushd lucene
ant filter-pom-templates -Divy.mode=local -Dversion=%{version}
for pom in `find build/poms/lucene -name pom.xml`; do
    sed 's/\${module-path}/${basedir}/g' "$pom" > "${pom##build/poms/lucene/}"
done
%pom_disable_module src/test core
%pom_disable_module src/test codecs
%pom_add_dep org.ow2.asm:asm::test demo
%pom_add_dep org.ow2.asm:asm-commons::test demo
%pom_add_dep org.antlr:antlr-runtime::test demo
popd
mv lucene/build/poms/pom.xml .
%pom_disable_module solr
%pom_remove_plugin :gmaven-plugin
%pom_remove_plugin -r :forbiddenapis
%pom_remove_dep org.eclipse.jetty.orbit:javax.servlet
%pom_change_dep org.eclipse.jetty.orbit:javax.servlet javax.servlet:javax.servlet-api:3.1.0 lucene/replicator
%pom_change_dep -r :servlet-api javax.servlet:javax.servlet-api:3.1.0
%pom_remove_plugin -r :maven-enforcer-plugin
%mvn_build -f

%install
%mvn_install

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

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

%changelog
* Thu Jul 30 2020 leiju <leiju4@huawei.com> - 4.10.4-1
- Package init
