Package proxool: Specfile

Packager: Igor Vlasenko <viy@altlinux.ru>
BuildRequires: checkstyle
%define _without_hibernate 1
BuildRequires: /proc
BuildRequires: jpackage-compat
# Copyright (c) 2000-2005, JPackage Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the
#    distribution.
# 3. Neither the name of the JPackage Project nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

# If you want to build with a (non fatal) checkstyle report
# give rpmbuild option '--with checkstyle'

%define with_checkstyle %{?_with_checkstyle:1}%{!?_with_checkstyle:0}
%define without_checkstyle %{!?_with_checkstyle:1}%{?_with_checkstyle:0}

# If you don't want to build with hibernate testing,
# while hibernate3 isn't available yet,
# give rpmbuild option '--without hibernate'

%define with_hibernate %{!?_without_hibernate:1}%{?_without_hibernate:0}
%define without_hibernate %{?_without_hibernate:1}%{!?_without_hibernate:0}



%define base_name proxool

Summary:        Proxool Java connection pool
Name:           %{base_name}
Version:        0.8.3
Release:        alt4_10jpp5
Epoch:          0
License:        Open Source
URL:            http://proxool.sourceforge.net/
Group:          Development/Java
Source0:        proxool-0.8.3-source.tar.gz
Source1:        proxool-sun_checks.xml
Patch0:         proxool-hsqldb-1.72.patch
Patch1:         proxool-0.8.3-build_xml.patch
Patch2:         proxool-checkstyle.patch
Patch3:         proxool-omit-hibernate-test.patch
Patch4:         proxool-HibernateTest.patch
Patch5:         proxool-TestConstants.patch
BuildRequires: jpackage-utils >= 0:1.6
BuildRequires: ant >= 0:1.6
BuildRequires: ant-junit
BuildRequires: jakarta-commons-collections
BuildRequires: jakarta-commons-logging
BuildRequires: excalibur-component
BuildRequires: excalibur-instrument-api
BuildRequires: excalibur-logger
BuildRequires: excalibur-pool-api
BuildRequires: excalibur-avalon-framework-api
BuildRequires: excalibur-avalon-framework-impl
BuildRequires: excalibur-avalon-logkit
%if %{with_checkstyle}
BuildRequires: checkstyle
%endif
BuildRequires: dom4j
BuildRequires: ehcache
BuildRequires: geronimo-jta-1.0.1B-api
%if %{with_hibernate}
BuildRequires: hibernate3
%endif
BuildRequires: hsqldb
BuildRequires: junit
BuildRequires: log4j
BuildRequires: mx4j
BuildRequires: servlet >= 2.3
Requires: alternatives >= 0:0.4.0
Requires: excalibur-component
Requires: excalibur-avalon-framework-api
Requires: excalibur-avalon-framework-impl
Requires: excalibur-avalon-logkit
Requires: dom4j
Requires: ehcache
Requires: jta
Requires: mx4j
Requires: servlet >= 2.3
Provides:  hibernate_jdbc_cache
BuildArch:      noarch

%description
Transparently adds connection pooling to your existing JDBC driver.
Our licence allows you flexibility to use it in both commercial and 
other open source products.
Complies with the J2SE API, giving you the confidence to develop to 
standards. You can monitor the performance of your database 
connections and listen to connection events.
It's easy to configure using the JDBC API, XML, or Java property 
files - you decide.

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

%description javadoc
%{summary}.

%package manual
Summary:        Documents for %{name}
Group:          Development/Documentation

%description manual
%{summary}.

%prep
cat <<EOT

		If you want to build with a (non fatal) checkstyle report
		give rpmbuild option '--with checkstyle'

		If you don't want to build with hibernate testing,
		while hibernate3 isn't available yet,
		give rpmbuild option '--without hibernate'

EOT

%setup -q -n %{base_name}-%{version}
find . -name "*.jar" -exec rm {} \;
#for j in $(find . -name "*.jar"); do
#	mv $j $j.no
#done
cp %{SOURCE1} sun_checks.xml
echo >> src/java-test/org/logicalcobwebs/proxool/ProxyStatementTest.java
%if %{with_hibernate}
for f in $(find . -name "*.java" -exec grep -l hibernate {} \;); do
    sed -e 's/net\.sf\.hibernate\./org.hibernate./' $f > tempf
    cp tempf $f
done
rm tempf
%else
rm src/java-test/org/logicalcobwebs/proxool/HibernateTest.java
%endif

%patch0 -b .sav
%patch1 -b .sav
%if %{with_checkstyle}
%patch2 -b .sav2
%endif
%if %{without_hibernate}
%patch3 -b .sav
%endif
#%patch4 -b .sav
%patch5 -b .sav

%build
pushd lib
ln -s $(build-classpath commons-collections) .
ln -s $(build-classpath commons-logging) .
ln -s $(build-classpath ehcache) .
ln -s $(build-classpath excalibur/excalibur-component) .
ln -s $(build-classpath excalibur/excalibur-instrument-api) .
ln -s $(build-classpath excalibur/excalibur-logger) .
ln -s $(build-classpath excalibur/excalibur-pool-api) .
ln -s $(build-classpath excalibur/avalon-framework-api) .
ln -s $(build-classpath excalibur/avalon-framework-impl) .
ln -s $(build-classpath excalibur/avalon-logkit) .
ln -s $(build-classpath dom4j) .
ln -s $(build-classpath geronimo-jta-1.0.1B-api) .
ln -s $(build-classpath checkstyle) .
ln -s $(build-classpath hsqldb) .
ln -s $(build-classpath junit) .
ln -s $(build-classpath log4j) .
ln -s $(build-classpath mx4j/mx4j) .
ln -s $(build-classpath servletapi) .
popd

export CLASSPATH=
%if %{with_checkstyle}
ant -Dant.build.javac.source=1.4 -Dant.build.javac.target=1.4 -Dtest=true checkstyle build-jar javadoc test produce-test-report 
%else
ant -Dant.build.javac.source=1.4 -Dant.build.javac.target=1.4 -Dtest=true build-jar javadoc test produce-test-report 
%endif

%install

# jars
mkdir -p $RPM_BUILD_ROOT%{_javadir}
cp -p build/%{base_name}-%{version}.jar \
      $RPM_BUILD_ROOT%{_javadir}/%{name}-%{version}.jar
(cd $RPM_BUILD_ROOT%{_javadir} && for jar in *-%{version}.jar; do ln -sf ${jar} `echo $jar| sed "s|-%{version}||g"`; done)

# javadoc
mkdir -p $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -pr doc/api/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
ln -s %{name}-%{version} $RPM_BUILD_ROOT%{_javadocdir}/%{name} # ghost symlink
rm -rf doc/api
rm -rf doc/api-dev

#manual
mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
cp -pr doc/* $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
cp *.txt $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}

# hibernate_jdbc_cache ghost symlink
ln -s %{_sysconfdir}/alternatives \
  $RPM_BUILD_ROOT%{_javadir}/hibernate_jdbc_cache.jar
install -d $RPM_BUILD_ROOT/%_altdir; cat >$RPM_BUILD_ROOT/%_altdir/hibernate_jdbc_cache_%{name}<<EOF
%{_javadir}/hibernate_jdbc_cache.jar	%{_javadir}/%{name}.jar	40
EOF

%post javadoc
rm -f %{_javadocdir}/%{name}
ln -s %{name}-%{version} %{_javadocdir}/%{name}

%postun javadoc
if [ "$1" = "0" ]; then
  rm -f %{_javadocdir}/%{name}
fi

%files
%_altdir/hibernate_jdbc_cache_%{name}
%doc %{_docdir}/%{name}-%{version}/LICENCE.txt
%{_javadir}/*.jar
%exclude %{_javadir}/hibernate_jdbc_cache.jar
# The package does not own its own docdir subdirectory.
# The line below is added by repocop to fix this bug in a straightforward way. 
# Another way is to rewrite the spec to use relative doc paths.
%dir %_docdir/proxool-%version 


%files javadoc
%doc %{_javadocdir}/%{name}-%{version}
%ghost %doc %{_javadocdir}/%{name}

%files manual
%doc %{_docdir}/%{name}-%{version}

%changelog
* Wed May 13 2009 Igor Vlasenko <viy@altlinux.ru> 0:0.8.3-alt4_10jpp5
- repocop bugfixes

* Sat Oct 18 2008 Igor Vlasenko <viy@altlinux.ru> 0:0.8.3-alt3_10jpp5
- fixed build with java 5

* Mon Mar 24 2008 Igor Vlasenko <viy@altlinux.ru> 0:0.8.3-alt2_10jpp1.7
- fixed alternatives intersection

* Sat Nov 24 2007 Igor Vlasenko <viy@altlinux.ru> 0:0.8.3-alt1_10jpp1.7
- converted from JPackage by jppimport script