Package spice-cop: Specfile

BuildRequires: /proc
BuildRequires: jpackage-compat
# Copyright (c) 2000-2007, 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.
#

%define gcj_support 0

# If you don't want to build with maven, and use straight ant instead,
# give rpmbuild option '--without maven'

%define with_maven %{!?_without_maven:1}%{?_without_maven:0}
%define without_maven %{?_without_maven:1}%{!?_without_maven:0}



Name:           spice-cop
Summary:        SPICE component repository
Url:            http://spice.codehaus.org/
Version:        1.0
Release:        alt1_4jpp5
Epoch:          0
License:        Open Source
Group:          Development/Java

Source0:        spice-%{version}-src.tar.gz
##cvs -d :pserver:anonymous@cvs.spice.codehaus.org:/home/projects/spice/scm login
##cvs -z3 -d :pserver:anonymous@cvs.spice.codehaus.org:/home/projects/spice/scm co spice
Source1:        pom-maven2jpp-depcat.xsl
Source2:        pom-maven2jpp-newdepmap.xsl
Source3:        pom-maven2jpp-mapdeps.xsl
Source4:        spice-%{version}-jpp-depmap.xml
Source5:        spice-cop-build.xml
Source6:        spice-cop-components-jndikit-build.xml
Source7:        spice-cop-components-configkit-build.xml
Source8:        spice-cop-components-salt-build.xml
Source9:        spice-cop-site-build.xml

Patch0:         spice-%{version}-project.patch

%if %{with_maven}
BuildRequires: maven-plugins
BuildRequires: saxon
BuildRequires: saxon-scripts
BuildRequires: jakarta-commons-jelly-tags-velocity
%endif
BuildRequires: ant
BuildRequires: junit
BuildRequires: excalibur-avalon-framework-api
BuildRequires: jakarta-commons-collections
BuildRequires: jakarta-commons-pool
BuildRequires: isorelax
BuildRequires: msv-strict
BuildRequires: relaxngDatatype
BuildRequires: velocity
BuildRequires:msv-xsdlib
%if %{with_maven}
Requires: jakarta-commons-jelly-tags-velocity
%endif
Requires: excalibur-avalon-framework-api
Requires: jakarta-commons-collections
Requires: jakarta-commons-pool
Requires: isorelax
Requires: msv-strict
Requires: relaxngDatatype
Requires: velocity
Requires:msv-xsdlib
%if ! %{gcj_support}
BuildArch:      noarch
%endif
%if %{gcj_support}
BuildRequires: gnu-crypto
BuildRequires: java-gcj-compat-devel
Requires(post): java-gcj-compat
Requires(postun): java-gcj-compat
%endif

%description
Spice is a repository of Components which support 
Component Oriented Programming (COP) paradigms - 
in particular, the Inversion of Control (IoC) 
design pattern. 
Our aim is to developed components that are: 
highly reusable - leveraging on IoC 
deployable both in client and server containers 
well tested - with high unit test coverage 
The Components are designed to support deployment in 
different containers or frameworks. 
JContainer DNA is a framework supporting IoC. 
JContainer Loom is a container designed and implemented 
on top of the DNA framework, which also supports 
applications written in the Avalon framework. 
Pico Container supports IoC in a more agile and 
embeddable way, without the need to import any 
external interface or class. 
Plexus is a container designed and implemented on 
top of the DNA and Avalon Frameworks. 


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

%description javadoc
Javadoc for %{name}.

%prep
%setup -q -n spice-%{version}

cp %{SOURCE5} build.xml
cp %{SOURCE6} components/jndikit/build.xml
cp %{SOURCE7} components/configkit/build.xml
cp %{SOURCE8} components/salt/build.xml
cp %{SOURCE9} site/build.xml

rm -rf sandbox
rm -rf components/alchemist
rm -rf components/loggerstore
rm -rf components/netserve
rm -rf components/threadpool
rm components/configkit/src/test/org/codehaus/spice/configkit/ConfigValidatorTestCase.java

%patch0 -p0

chmod -R go=u-w *
find . -name "*.jar" -exec rm -f {} \;

%build
%if %{with_maven}
export DEPCAT=$(pwd)/spice-1.0-depcat.new.xml
echo '<?xml version="1.0" standalone="yes"?>' > $DEPCAT
echo '<depset>' >> $DEPCAT
for p in $(find . -name project.xml); do
    pushd $(dirname $p)
    /usr/bin/saxon project.xml %{SOURCE1} >> $DEPCAT
    popd
done
echo >> $DEPCAT
echo '</depset>' >> $DEPCAT
/usr/bin/saxon $DEPCAT %{SOURCE2} > spice-1.0-depmap.new.xml


for p in $(find . -name project.xml); do
    pushd $(dirname $p)
    cp project.xml project.xml.orig
    /usr/bin/saxon -o project.xml project.xml.orig %{SOURCE3} map=%{SOURCE4}
    popd
done

export MAVEN_HOME_LOCAL=$(pwd)/.maven
maven \
    -Dmaven.compile.target=1.4 -Dmaven.javadoc.source=1.4 \
    -Dmaven.repo.remote=file:/usr/share/maven/repository \
    -Dmaven.home.local=${MAVEN_HOME_LOCAL} components:build
for c in configkit jndikit salt ; do
pushd components/$c
maven \
    -Dmaven.compile.target=1.4 -Dmaven.javadoc.source=1.4 \
    -Dmaven.repo.remote=file:/usr/share/maven/repository \
    -Dmaven.home.local=${MAVEN_HOME_LOCAL} javadoc
popd
done

%else

export CLASSPATH=$(build-classpath isorelax msv-msv msv-xsdlib relaxngDatatype):target/classes:target/test-classes:src/test
for c in configkit jndikit salt ; do
pushd components/$c
ant -Dbuild.sysclasspath=only -Dant.build.javac.source=1.4 -Dant.build.javac.target=1.4 jar javadoc
popd
done

%endif

%install
# jars
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}/%{name}
install -m 644 components/configkit/target/spice-configkit-1.3-dev.jar \
        $RPM_BUILD_ROOT%{_javadir}/%{name}/configkit-1.3-%{version}.jar
install -m 644 components/jndikit/target/spice-jndikit-1.1.jar \
        $RPM_BUILD_ROOT%{_javadir}/%{name}/jndikit-1.1-%{version}.jar
install -m 644 components/salt/target/spice-salt-1.1-dev.jar \
        $RPM_BUILD_ROOT%{_javadir}/%{name}/salt-1.1-%{version}.jar

pushd $RPM_BUILD_ROOT%{_javadir}/%{name} 
 for jar in *-%{version}*; do 
  ln -sf ${jar} `echo $jar| sed  "s|-%{version}||g"`; 
 done
 for jar in *-[0-9].[0-9].jar; do 
  ln -sf ${jar} `echo $jar| sed  "s|-[0-9]\.[0-9]||g"`; 
 done
popd

# javadoc
install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
for c in configkit jndikit salt ; do
    install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}/$c
    cp -pr components/$c/target/docs/apidocs/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}/$c
done
ln -s %{name}-%{version} $RPM_BUILD_ROOT%{_javadocdir}/%{name} # ghost symlink

%if %{gcj_support}
export CLASSPATH=$(build-classpath gnu-crypto)
%{_bindir}/aot-compile-rpm
%endif

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

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

%if %{gcj_support}
%post
if [ -x %{_bindir}/rebuild-gcj-db ]
then
  %{_bindir}/rebuild-gcj-db
fi
%endif

%if %{gcj_support}
%postun
if [ -x %{_bindir}/rebuild-gcj-db ]
then
  %{_bindir}/rebuild-gcj-db
fi
%endif

%files
%doc *.txt
%{_javadir}/%{name}
%if %{gcj_support}
%dir %attr(-,root,root) %{_libdir}/gcj/%{name}
%{_libdir}/gcj/%{name}/configkit-1.3-%{version}.jar.*
%{_libdir}/gcj/%{name}/jndikit-1.1-%{version}.jar.*
%{_libdir}/gcj/%{name}/salt-1.1-%{version}.jar.*
%endif

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

%changelog
* Tue Nov 11 2008 Igor Vlasenko <viy@altlinux.ru> 0:1.0-alt1_4jpp5
- java 5 fix

* Fri Aug 10 2007 Igor Vlasenko <viy@altlinux.ru> 0:1.0-alt1_4jpp1.7
- converted from JPackage by jppimport script