Blob Blame History Raw
%{?scl:%scl_package xml-commons-apis}
%{!?scl:%global pkg_name %{name}}
%{!?maven_scl:%global maven_scl_prefix  %{nil}}

Name:          %{?scl_prefix}xml-commons-apis
Version:       1.4.01
Release:       12.2%{?dist}
Summary:       APIs for DOM, SAX, and JAXP
Group:         Development/Libraries
License:       ASL 2.0 and W3C and Public Domain
URL:           http://xml.apache.org/commons/

# From source control because the published tarball doesn't include some docs:
#   svn export http://svn.apache.org/repos/asf/xml/commons/tags/xml-commons-external-1_4_01/java/external/
#   tar czf xml-commons-external-1.4.01-src.tar.gz external
Source0:       xml-commons-external-%{version}-src.tar.gz
Source1:       %{pkg_name}-MANIFEST.MF
Source2:       %{pkg_name}-ext-MANIFEST.MF
Source3:       http://repo1.maven.org/maven2/xml-apis/xml-apis/2.0.2/xml-apis-2.0.2.pom
Source4:       http://repo1.maven.org/maven2/xml-apis/xml-apis-ext/1.3.04/xml-apis-ext-1.3.04.pom

BuildArch:     noarch

BuildRequires: java-devel >= 1:1.6.0
BuildRequires: jpackage-utils
BuildRequires: ant
BuildRequires: zip
BuildRequires: %{maven_scl_prefix}maven-local
Requires:      java
Requires:      jpackage-utils
Requires(post):    jpackage-utils
Requires(postun):  jpackage-utils

Obsoletes:     %{?scl_prefix}xml-commons < %{version}-%{release}
Provides:      %{?scl_prefix}xml-commons = %{version}-%{release}

%description
xml-commons-apis is designed to organize and have common packaging for
the various externally-defined standard interfaces for XML. This
includes the DOM, SAX, and JAXP.

%package manual
Summary:       Manual for %{name}
Group:         Documentation

%description manual
%{summary}.

%package javadoc
Summary:       Javadoc for %{name}
Group:         Documentation

%description javadoc
%{summary}.

%prep
%setup -q -n external
# Make sure upstream hasn't sneaked in any jars we don't know about
find -name '*.class' -exec rm -f '{}' \;
find -name '*.jar' -exec rm -f '{}' \;

# Fix file encodings
iconv -f iso8859-1 -t utf-8 LICENSE.dom-documentation.txt > \
  LICENSE.dom-doc.temp && mv -f LICENSE.dom-doc.temp LICENSE.dom-documentation.txt
iconv -f iso8859-1 -t utf-8 LICENSE.dom-software.txt > \
  LICENSE.dom-sof.temp && mv -f LICENSE.dom-sof.temp LICENSE.dom-software.txt

# remove bogus section from poms
cp %{SOURCE3} %{SOURCE4} .
sed -i '/distributionManagement/,/\/distributionManagement/ {d}' *.pom

%build
ant -Dant.build.javac.source=1.5 -Dant.build.javac.target=1.5 jar javadoc

%install
# inject OSGi manifests
mkdir -p META-INF
cp -p %{SOURCE1} META-INF/MANIFEST.MF
touch META-INF/MANIFEST.MF
zip -u build/xml-apis.jar META-INF/MANIFEST.MF
cp -p %{SOURCE2} META-INF/MANIFEST.MF
touch META-INF/MANIFEST.MF
zip -u build/xml-apis-ext.jar META-INF/MANIFEST.MF

# Jars
install -pD -T build/xml-apis.jar %{buildroot}%{_javadir}/%{pkg_name}.jar
install -pDm 644 xml-apis-[0-9]*.pom %{buildroot}%{_mavenpomdir}/JPP-%{pkg_name}.pom
scl enable %{scl} - <<"EOF"
%add_maven_depmap JPP-%{pkg_name}.pom %{pkg_name}.jar
EOF
scl enable %{scl} - <<"EOF"
%add_maven_depmap -a xerces:dom3-xml-apis
EOF

install -pD -T build/xml-apis-ext.jar %{buildroot}%{_javadir}/%{pkg_name}-ext.jar
install -pDm 644 xml-apis-ext*.pom %{buildroot}%{_mavenpomdir}/JPP-%{pkg_name}-ext.pom
scl enable %{scl} - <<"EOF"
%add_maven_depmap JPP-%{pkg_name}-ext.pom %{pkg_name}-ext.jar
EOF

# for better interoperability with the jpp apis packages
ln -sf %{pkg_name}.jar %{buildroot}%{_javadir}/jaxp13.jar
ln -sf %{pkg_name}.jar %{buildroot}%{_javadir}/jaxp.jar
ln -sf %{pkg_name}.jar %{buildroot}%{_javadir}/xml-commons-jaxp-1.3-apis.jar

# Javadocs
mkdir -p %{buildroot}%{_javadocdir}/%{pkg_name}
cp -pr build/docs/javadoc/* %{buildroot}%{_javadocdir}/%{pkg_name}

# prevent apis javadoc from being included in doc
rm -rf build/docs/javadoc

%pre javadoc
# workaround for rpm bug, can be removed in F-18
[ $1 -gt 1 ] && [ -L %{_javadocdir}/%{pkg_name} ] && \
rm -rf $(readlink -f %{_javadocdir}/%{pkg_name}) %{_javadocdir}/%{pkg_name} || :

%files
%doc LICENSE NOTICE
%doc LICENSE.dom-documentation.txt README.dom.txt
%doc LICENSE.dom-software.txt LICENSE.sac.html
%doc LICENSE.sax.txt README-sax  README.sax.txt
%{_javadir}/*
%{_mavendepmapfragdir}/%{pkg_name}
%{_mavenpomdir}/JPP-%{pkg_name}.pom
%{_mavenpomdir}/JPP-%{pkg_name}-ext.pom

%files manual
%doc build/docs/*

%files javadoc
%{_javadocdir}/*

%changelog
* Fri Oct 10 2014 Mat Booth <mat.booth@redhat.com> - 1.4.01-12.2
- Resolves: rhbz#1146976 - Drop conflicting provides

* Wed May 21 2014 Alexander Kurtakov <akurtako@redhat.com> 1.4.01-12.1
- Switch java-headless to java for RHEL 6.

* Tue May 20 2014 Jeff Johnston <jjohnstn@redhat.com> - 1.4.01-1
- SCL-ize updated version from rawhide.