%global gittag %(v=%{version}; echo "release-$v" | sed 's/\\./-/')
%global srctgz %(v=%{version}; echo "icu4j-$v" | sed 's/\\./_/')
Name:                icu4j
Version:             63.2
Release:             2
Epoch:               1
Summary:             International Components for Unicode for Java
License:             Unicode and MIT and BSD and Public Domain
URL:                 https://github.com/unicode-org/icu/
Source0:             https://github.com/unicode-org/icu/releases/download/release-63-2/icu4j-63_2.tgz
Source1:             https://repo1.maven.org/maven2/com/ibm/icu/icu4j/%{version}/icu4j-%{version}.pom
Source2:             https://repo1.maven.org/maven2/com/ibm/icu/icu4j-charset/%{version}/icu4j-charset-%{version}.pom
Source3:             https://repo1.maven.org/maven2/com/ibm/icu/icu4j-localespi/%{version}/icu4j-localespi-%{version}.pom
Patch0:              improve-osgi-manifest.patch
Patch1:              Fix-compilation-failures-caused-by-hamcrest-upgrade.patch
BuildRequires:       ant ant-junit java-javadoc javapackages-local ivy-local
BuildArch:           noarch
%description
The International Components for Unicode (ICU) library provides robust and
full-featured Unicode services on a wide variety of platforms. ICU supports
the most current version of the Unicode standard, and provides support for
supplementary characters (needed for GB 18030 repertoire support).
Java provides a very strong foundation for global programs, and IBM and the
ICU team played a key role in providing globalization technology into Sun's
Java. But because of its long release schedule, Java cannot always keep
up-to-date with evolving standards. The ICU team continues to extend Java's
Unicode and internationalization support, focusing on improving
performance, keeping current with the Unicode standard, and providing
richer APIs, while remaining as compatible as possible with the original
Java text and internationalization API design.

%package charset
Summary:             Charset converter library of %{name}
%description charset
Charset converter library of %{name}.

%package localespi
Summary:             Locale SPI library of %{name}
%description localespi
Locale SPI library of %{name}.

%package javadoc
Summary:             Javadoc for %{name}
Requires:            java-javadoc
%description javadoc
API documentation for %{name}.

%prep
%setup -q -c
%patch0
%patch1
sed -i -e 's/junit-4.12/junit-SYSTEM/' \
       -e 's/hamcrest-core-1.3/hamcrest-core-SYSTEM/' build.xml
sed -i -e '/pl.pragmatists/d' ivy.xml
rm main/tests/core/src/com/ibm/icu/dev/test/format/DataDrivenFormatTest.java
rm main/tests/core/src/com/ibm/icu/dev/test/calendar/DataDrivenCalendarTest.java
rm main/tests/core/src/com/ibm/icu/dev/test/serializable/CompatibilityTest.java
rm main/tests/core/src/com/ibm/icu/dev/test/serializable/CoverageTest.java
rm main/tests/charset/src/com/ibm/icu/dev/test/charset/TestConversion.java
rm main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorDisorderedMarksTest.java
rm main/tests/charset/src/com/ibm/icu/dev/test/charset/TestSelection.java
rm main/tests/charset/src/com/ibm/icu/dev/test/charset/TestCharset.java
rm main/tests/core/src/com/ibm/icu/dev/test/format/TimeZoneFormatTest.java

%build
export JAVA_HOME=%{_jvmdir}/java/
mkdir -p ~/.ant/lib
ant -Divy.mode=local -Doffline=true -Dicu4j.api.doc.jdk.link=%{_javadocdir}/java \
  all check
mkdir -p maven/icu4j{,-charset,-localespi}
cp -p %{SOURCE1} maven/icu4j/pom.xml
cp -p %{SOURCE2} maven/icu4j-charset/pom.xml
cp -p %{SOURCE3} maven/icu4j-localespi/pom.xml
for jar in icu4j icu4j-charset icu4j-localespi ; do
  sed -i -e 's/@POMVERSION@/%{version}/' maven/$jar/pom.xml
  %mvn_artifact maven/$jar/pom.xml $jar.jar
  %mvn_package :$jar $jar
done

%install
%mvn_install -J doc
install -m 644 icu4j-charset.jar   %{buildroot}%{_javadir}/icu4j/
install -m 644 icu4j-localespi.jar %{buildroot}%{_javadir}/icu4j/

%files -f .mfiles-icu4j
%license main/shared/licenses/*
%doc readme.html APIChangeReport.html

%files charset -f .mfiles-icu4j-charset

%files localespi -f .mfiles-icu4j-localespi

%files javadoc -f .mfiles-javadoc
%license main/shared/licenses/*

%changelog
* Thu Sep 28 2023 liyanan <thistleslyn@163.com> - 1:63.2-2
- Fixed compilation failures caused by hamcrest upgrade

* Sat Aug 1 2020 chengzihan <chengzihan2@huawei.com> - 63.2-1
- Package init
