File apache-commons-logging.spec of Package apache-commons-logging

#
# spec file for package apache-commons-logging
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2000-2007, JPackage Project
# All rights reserved.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define base_name  logging
%define short_name commons-%{base_name}
%define with_maven 0
%define _mavenpomdir %{_datadir}/maven2/poms

Name:           apache-%{short_name}
Version:        1.1.1
Release:        0
Summary:        Apache Commons Logging
License:        Apache-2.0
Group:          Development/Libraries/Java
Url:            http://commons.apache.org/%{base_name}
Source0:        http://www.apache.org/dist/commons/%{base_name}/source/%{short_name}-%{version}-src.tar.gz
Source1:        %{short_name}.depmap
Source2:        http://mirrors.ibiblio.org/pub/mirrors/maven2/%{short_name}/%{short_name}-api/1.1/%{short_name}-api-1.1.pom
Patch1:         %{short_name}-eclipse-manifest.patch
Patch0:         %{short_name}-maven-release-plugin.patch
Patch2:         build.xml.patch
BuildRequires:  ant
BuildRequires:  ant-junit
BuildRequires:  apache-commons-parent
BuildRequires:  java-devel >= 1.6.0
BuildRequires:  jpackage-utils >= 1.6
BuildRequires:  junit
%if %{with_maven}
BuildRequires:  maven-plugin-build-helper
BuildRequires:  maven-site-plugin
%endif
BuildRequires:  servletapi5
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

Requires:       java >= 1.6.0
Requires:       jpackage-utils >= 1.6
Requires(post): jpackage-utils
Requires(postun):jpackage-utils

Provides:       jakarta-%{short_name} = %{version}-%{release}
Obsoletes:      jakarta-%{short_name} <= 1.0.4
Provides:       %{short_name} = %{version}-%{release}

%description
The commons-logging package provides a simple, component oriented
interface (org.apache.commons.logging.Log) together with wrappers for
logging systems. The user can choose at runtime which system they want
to use. In addition, a small number of basic implementations are
provided to allow users to use the package standalone.
commons-logging was heavily influenced by Avalon's Logkit and Log4J. The
commons-logging abstraction is meant to minimize the differences between
the two, and to allow a developer to not tie himself to a particular
logging implementation.

%if %{with_maven}
%package        javadoc
Summary:        API documentation for %{name}
Group:          Documentation
Requires:       jpackage-utils

Obsoletes:      jakarta-%{short_name}-javadoc <= 1.0.4

%description    javadoc
API documentation for %{name}.
%endif
# -----------------------------------------------------------------------------

%prep
%setup -q -n %{short_name}-%{version}-src
%patch0 -p1 -b .rhbug_588142
%patch1
%patch2

sed -i 's/\r//' RELEASE-NOTES.txt LICENSE.txt

# -----------------------------------------------------------------------------

%build
export MAVEN_REPO_LOCAL=$(pwd)/.m2/repository
mkdir -p $MAVEN_REPO_LOCAL

# fails with recent surefire for some reason
rm src/test/org/apache/commons/logging/logkit/StandardTestCase.java
rm src/test/org/apache/commons/logging/servlet/BasicServletTestCase.java

%if %{with_maven}
mvn-jpp -e -Dmaven2.jpp.depmap.file="%{SOURCE1}" \
    -Dmaven.repo.local=$MAVEN_REPO_LOCAL \
    install javadoc:javadoc
%else
export CLASSPATH=$(build-classpath \
                   plexus/ \
                   junit \
                  ):target/classes:target/test-classes
ant -Dmaven.mode.offline=true dist \
    -lib /usr/share/java
%endif
# -----------------------------------------------------------------------------

%install
# jars
install -d -m 755 %{buildroot}%{_javadir}
install -p -m 644 target/%{short_name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar
install -p -m 644 target/%{short_name}-api-%{version}.jar %{buildroot}%{_javadir}/%{name}-api.jar
install -p -m 644 target/%{short_name}-adapters-%{version}.jar %{buildroot}%{_javadir}/%{name}-adapters.jar

pushd %{buildroot}%{_javadir}
for jar in %{name}*; do
    ln -sf ${jar} `echo $jar| sed "s|apache-||g"`
done
popd

# pom
install -d -m 755 %{buildroot}%{_mavenpomdir}
install -pm 644 pom.xml %{buildroot}/%{_mavenpomdir}/JPP-%{short_name}.pom
install -pm 644 %{SOURCE2} %{buildroot}/%{_mavenpomdir}/JPP-%{short_name}-api.pom

%add_to_maven_depmap org.apache.commons %{short_name} %{version} JPP %{short_name}
%add_to_maven_depmap org.apache.commons %{short_name}-api %{version} JPP %{short_name}-api
%add_to_maven_depmap org.apache.commons %{short_name}-adapters %{version} JPP %{short_name}-adapters

# following lines are only for backwards compatibility. New packages
# should use proper groupid org.apache.commons and also artifactid
%add_to_maven_depmap %{short_name} %{short_name} %{version} JPP %{short_name}
%add_to_maven_depmap %{short_name} %{short_name}-api %{version} JPP %{short_name}-api
%add_to_maven_depmap %{short_name} %{short_name}-adapters %{version} JPP %{short_name}-adapters

%if %{with_maven}
# javadoc
install -d -m 755 %{buildroot}%{_javadocdir}/%{name}
cp -pr target/site/apidocs/* %{buildroot}%{_javadocdir}/%{name}
# -----------------------------------------------------------------------------
%endif
%post
%update_maven_depmap

%postun
%update_maven_depmap

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

# -----------------------------------------------------------------------------

%files
%defattr(0644,root,root,0755)
%doc PROPOSAL.html STATUS.html LICENSE.txt RELEASE-NOTES.txt
%{_javadir}/*
%{_mavenpomdir}/JPP-%{short_name}.pom
%{_mavenpomdir}/JPP-%{short_name}-api.pom
%config %{_mavendepmapfragdir}/*

%if %{with_maven}
%files javadoc
%defattr(0644,root,root,0755)
%doc LICENSE.txt
%{_javadocdir}/%{name}
%endif

# -----------------------------------------------------------------------------

%changelog
openSUSE Build Service is sponsored by