Name:                ldapjdk
Summary:             LDAP SDK
URL:                 http://www.dogtagpki.org/
License:             MPLv1.1 or GPLv2+ or LGPLv2+
BuildArch:           noarch
Version:             5.1.0
Release:             2
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
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}
install -m 644 %{_vpath_builddir}/packages/ldapjdk.jar $RPM_BUILD_ROOT%{_javadir}/ldapjdk.jar
install -m 644 %{_vpath_builddir}/packages/ldapsp.jar $RPM_BUILD_ROOT%{_javadir}/ldapsp.jar
install -m 644 %{_vpath_builddir}/packages/ldapfilt.jar $RPM_BUILD_ROOT%{_javadir}/ldapfilt.jar
install -m 644 %{_vpath_builddir}/packages/ldapbeans.jar $RPM_BUILD_ROOT%{_javadir}/ldapbeans.jar
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}-1.3.0
pushd $RPM_BUILD_ROOT%{_javadir}-1.3.0
	ln -fs ../java/*ldapsp.jar jndi-ldap.jar
popd
mkdir -p %{buildroot}%{_mavenpomdir}
sed -i 's/4.22.1-SNAPSHOT/%{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"
install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/ldapjdk
cp -r %{_vpath_builddir}/doc/* $RPM_BUILD_ROOT%{_javadocdir}/ldapjdk


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

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

%changelog
* 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
