Package jakarta-commons-javaflow: Specfile

Packager: Igor Vlasenko <viy@altlinux.ru>
BuildRequires: /proc
BuildRequires: jpackage-compat
# Copyright (c) 2000-2008, 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}

%define base_name commons-javaflow
%define svnrev 618928
%define namedversion 1.0-SNAPSHOT

Name:           jakarta-commons-javaflow
Version:        1.0
Release:        alt1_0.r618928.1jpp5
Epoch:          0
Summary:        Commons JavaFlow
License:        Apache License 2.0
Url:            http://commons.apache.org/sandbox/javaflow/
Group:          Development/Java
Source0:        %{base_name}-%{version}-r%{svnrev}.tar.gz
#svn export http://svn.apache.org/repos/asf/commons/sandbox/javaflow/trunk/ %{base_name}-%{version}

Source1:        %{base_name}-settings.xml
Source2:        %{base_name}-commons-sandbox.pom
Source3:        %{base_name}-%{version}-jpp-depmap.xml
Source4:        %{base_name}-autogenerated-files.tar.gz
Source5:        commons-build.tar.gz
Patch0:         %{base_name}-%{version}-site_xml.patch
Patch1:         %{base_name}-%{version}-navigation_xml.patch
Patch2:         %{base_name}-%{version}-pom.patch

BuildRequires: jpackage-utils >= 0:1.7.4
BuildRequires: ant >= 0:1.6.5
BuildRequires: junit
BuildRequires: junit-addons
%if %{with_maven}
BuildRequires: maven2-common-poms
BuildRequires: maven2 >= 0:2.0.7
BuildRequires: maven2-default-skin
BuildRequires: maven2-plugin-ant
BuildRequires: maven2-plugin-antrun
BuildRequires: maven2-plugin-changelog
BuildRequires: maven2-plugin-compiler
BuildRequires: maven2-plugin-idea
BuildRequires: maven2-plugin-install
BuildRequires: maven2-plugin-jar
BuildRequires: maven2-plugin-javadoc
BuildRequires: maven2-plugin-pmd
BuildRequires: maven2-plugin-project-info-reports
BuildRequires: maven2-plugin-resources
BuildRequires: maven2-plugin-site
BuildRequires: maven-surefire-plugin
BuildRequires: maven2-plugin-surefire-report
BuildRequires: mojo-maven2-plugin-cobertura
BuildRequires: mojo-maven2-plugin-taglist
%endif

BuildRequires: asm2 >= 0:2.2.3
BuildRequires: bcel
BuildRequires: jakarta-commons-io >= 0:1.3.2
BuildRequires: jakarta-commons-jci
BuildRequires: jakarta-commons-logging
BuildRequires: subversion

Requires: asm2 >= 0:2.2.3
Requires: bcel
Requires: jakarta-commons-io >= 0:1.3.2
Requires: jakarta-commons-jci
Requires: jakarta-commons-logging
BuildArch:      noarch

%description
Sometimes it is useful if we can capture the state of the application, 
its stack of function calls, which includes local variables, the global 
variables and the program counter, and save them into an object. If 
this object would give us the ability to restart the processing from 
the point stored in it. 
A continuation is exactly the type of object that we need. Think of a 
continuation as an object that, for a given point in your program, 
contains a snapshot of the stack trace, including all the local 
variables, and the program counter. You can not only store these 
things in the continuation object, but also restore the execution 
of the program from a continuation object. This means that the stack 
trace and the program counter of the running program become the ones 
stored in a continuation. 
Continuations are powerful concepts from the world of functional 
languages, like Scheme, but they are becoming popular in other 
languages as well. 


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

%description javadoc
%{summary}.

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

%description manual
%{summary}.
%endif

%prep
%setup -q -n %{base_name}-%{version}
#find . -name "*.jar" -exec rm -f {} \;
for j in $(find . -name "*.jar"); do
    mv $j $j.no
done
cp %{SOURCE1} settings.xml
%if %{without_maven}
gzip -dc %{SOURCE4} | tar xf -
%endif
gzip -dc %{SOURCE5} | tar xf -

sed -i -e "s|<url>__JPP_URL_PLACEHOLDER__</url>|<url>file://`pwd`/.m2/repository</url>|g" settings.xml
sed -i -e "s|<url>__JAVADIR_PLACEHOLDER__</url>|<url>file://`pwd`/external_repo</url>|g" settings.xml
sed -i -e "s|<url>__MAVENREPO_DIR_PLACEHOLDER__</url>|<url>file://`pwd`/.m2/repository</url>|g" settings.xml


%patch0 -b .sav0
%patch1 -b .sav1
%patch2 -b .sav2

%build
export JAVA_HOME=%{_jvmdir}/java-1.5.0

%if %{with_maven}
export MAVEN_REPO_LOCAL=$(pwd)/.m2/repository
mkdir -p $MAVEN_REPO_LOCAL/JPP/maven2/default_poms/
cp %{SOURCE2} $MAVEN_REPO_LOCAL/JPP/maven2/default_poms/org.apache.commons-commons-sandbox-parent.pom

mkdir external_repo
ln -s %{_javadir} external_repo/JPP

export M2_SETTINGS=$(pwd)/settings.xml
mvn-jpp \
        -e \
        -s $M2_SETTINGS \
        -Dmaven.test.failure.ignore=true \
        -Dmaven2.jpp.depmap.file=%{SOURCE3} \
        -Dmaven.repo.local=$MAVEN_REPO_LOCAL \
        ant:ant install javadoc:javadoc site
%else
export CLASSPATH=$(build-classpath \
asm2/asm2 \
asm2/asm2-analysis \
asm2/asm2-commons \
asm2/asm2-tree \
asm2/asm2-util \
bcel \
commons-io \
commons-jci-core \
commons-logging \
)
CLASSPATH=$CLASSPATH:target/classes:target/test-classes
ant -Dmaven.compile.source=1.4 -Dmaven.compile.target=1.5 -Dmaven.settings.offline=true -Dbuild.sysclasspath=only jar javadoc
%endif

%install
# jars
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}
install -m 644 target/javaflow-%{namedversion}.jar \
           $RPM_BUILD_ROOT%{_javadir}/%{name}-%{version}.jar
%add_to_maven_depmap org.apache.commons javaflow %{version} JPP %{base_name}

(cd $RPM_BUILD_ROOT%{_javadir} && for jar in jakarta-*; do \
ln -sf ${jar} ${jar/jakarta-/}; done)
(cd $RPM_BUILD_ROOT%{_javadir} && for jar in *-%{version}*; do \
ln -sf ${jar} ${jar/-%{version}/}; done)

# pom
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/maven2/poms
install -m 644 pom.xml $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP-%{base_name}.pom

# javadoc
install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -pr target/site/apidocs/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
ln -s %{name}-%{version} $RPM_BUILD_ROOT%{_javadocdir}/%{name} # ghost symlink

## manual
install -d -m 755 $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
cp -p LICENSE.txt $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
%if %{with_maven}
rm -rf target/site/apidocs
cp -pr target/site $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
%endif

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

%files
%doc %{_docdir}/%{name}-%{version}/LICENSE.txt
%{_javadir}/*
%{_datadir}/maven2
%{_mavendepmapfragdir}
# hack; explicitly added docdir if not owned
%doc %dir %{_docdir}/%{name}-%{version}

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

%if %{with_maven}
%files manual
%doc %{_docdir}/%{name}-%{version}/site
%endif
# hack; explicitly added docdir if not owned
%doc %dir %{_docdir}/%{name}-%{version}

%changelog
* Tue Mar 03 2009 Igor Vlasenko <viy@altlinux.ru> 0:1.0-alt1_0.r618928.1jpp5
- new version