Name:                ldapjdk
Summary:             LDAP SDK
URL:                 http://www.dogtagpki.org/
License:             MPLv1.1 or GPLv2+ or LGPLv2+
BuildArch:           noarch
Version:             5.4.1
Release:             1
Source:              https://github.com/dogtagpki/ldap-sdk/archive/v%{version}/ldap-sdk-%{version}.tar.gz
BuildRequires:       ant java-latest-openjdk-devel javapackages-local slf4j slf4j-jdk14 jss >= 5.1.0
Requires:            java-latest-openjdk-headless jpackage-utils >= 0:1.5 slf4j slf4j-jdk14 jss >= 5.1.0

%description
The Mozilla LDAP SDKs enable you to write applications which access,
manage, and update the information stored in an LDAP directory.
%license docs/ldapjdk/license.txt

%package javadoc
Summary:             Javadoc for ldapjdk
%description javadoc
Javadoc for ldapjdk

%prep
%autosetup -n ldap-sdk-%{version} -p 1

%build
openjdk_latest_version=`rpm -qi java-latest-openjdk-headless | grep Version | cut -b 15-16`
home_path=`ls /usr/lib/jvm | grep java-${openjdk_latest_version}-openjdk-${openjdk_latest_version}`
export JAVA_HOME=/usr/lib/jvm/${home_path}

./build.sh \
    %{?_verbose:-v} \
    --work-dir=%{_vpath_builddir} \
    dist

%install
./build.sh \
    %{?_verbose:-v} \
    --work-dir=%{_vpath_builddir} \
    --java-lib-dir=%{_javadir} \
    --javadoc-dir=%{_javadocdir} \
    --install-dir=%{buildroot} \
    install

mkdir -p %{buildroot}%{_mavenpomdir}
sed -i 's/5.4.0-SNAPSHOT/%{version}/g' pom.xml
sed -i 's/${revision}/%{version}/g' pom.xml
install -pm 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-ldapjdk.pom
%add_maven_depmap JPP-ldapjdk.pom ldapjdk.jar -a "ldapsdk:ldapsdk"

%files -f .mfiles
%{_javadir}/ldapjdk.jar
%{_javadir}/ldapsp.jar
%{_javadir}/ldapfilt.jar
%{_javadir}/ldapbeans.jar
%{_javadir}/ldaptools.jar
%{_mavenpomdir}/JPP-ldapjdk.pom
%{_mavenpomdir}/JPP-ldapsp.pom
%{_mavenpomdir}/JPP-ldapfilter.pom
%{_mavenpomdir}/JPP-ldapbeans.pom
%{_mavenpomdir}/JPP-ldaptools.pom

%files javadoc
%dir %{_javadocdir}/ldapjdk
%{_javadocdir}/ldapjdk/*

%changelog
* Fri Sep 15 2023 chenchen <chen_aka_jan@163.com> - 5.4.1-1
- Upgrade to version 5.4.1

* Wed Jan 18 2023 xu_ping <xuping33@h-partners.com> - 5.1.0-2
- DESC: fix get java_home error

* Thu Jun 2 2022 Ge Wang <wangge20@h-partners.com> - 5.1.0-1
- DESC: upgrade versoin to 5.1.0

* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 4.22.0-5
- DESC: delete -S git from %autosetup, and delete BuildRequires git

* Thu Jul 23 2020 yaokai <yaokai13@huawei.com> - 4.22.0-4
- Fix the wrong requires

* Thu Jul 16 2020 yaokai <yaokai13@huawei.com> - 4.22.0-3
- package init
