Name:                ldapjdk
Summary:             LDAP SDK
URL:                 http://www.dogtagpki.org/
License:             MPLv1.1 or GPLv2+ or LGPLv2+
BuildArch:           noarch
Version:             4.22.0
Release:             3
Source:              https://github.com/dogtagpki/ldap-sdk/archive/v%{version}/ldap-sdk-%{version}.tar.gz
BuildRequires:       git ant java-devel javapackages-local slf4j slf4j-jdk14 jss >= 4.6.0
Requires:            jpackage-utils >= 0:1.5 slf4 slf4j-jdk14 jss >= 4.6.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 -S git
rm -f ./java-sdk/ldapjdk/lib/{jss32_stub,jsse,jnet,jaas,jndi}.jar

%build
pwd
( cd  java-sdk/ldapjdk/lib && build-jar-repository -s -p . jss4 )
ln -s /usr/lib/jvm-exports/java/{jsse,jaas,jndi}.jar java-sdk/ldapjdk/lib
cd java-sdk
if [ ! -e "$JAVA_HOME" ] ; then export JAVA_HOME="%{_jvmdir}/java" ; fi
sh -x ant dist

%install
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}
install -m 644 java-sdk/dist/packages/ldapjdk.jar $RPM_BUILD_ROOT%{_javadir}/ldapjdk.jar
install -m 644 java-sdk/dist/packages/ldapsp.jar $RPM_BUILD_ROOT%{_javadir}/ldapsp.jar
install -m 644 java-sdk/dist/packages/ldapfilt.jar $RPM_BUILD_ROOT%{_javadir}/ldapfilt.jar
install -m 644 java-sdk/dist/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/@VERSION@/%{version}/g' ldapjdk.pom
install -pm 644 ldapjdk.pom %{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 java-sdk/dist/doc/* $RPM_BUILD_ROOT%{_javadocdir}/ldapjdk

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

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

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