Blob Blame History Raw
# 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 _without_maven 1

# 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 _without_tests 1
%define without_tests %{?_without_tests:1}%{!?_without_tests:%{?_with_tests:0}%{!?_with_tests:%{?_tests:%{_tests}}%{!?_tests:0}}}
%define gcj_support 0
%define base_name    net
%define short_name   commons-%{base_name}

Name:           jakarta-commons-net
Version:        1.4.1
Release:        4jpp.1%{?dist}
Epoch:          0
Summary:        Internet protocol suite Java library
License:        Apache Software License
Group:          Development/Libraries/Java
Url:            http://jakarta.apache.org/commons/%{base_name}/
Source0:        http://www.apache.org/dist/jakarta/commons/net/source/commons-net-1.4.1-src.tar.gz
Source1:        pom-maven2jpp-depcat.xsl
Source2:        pom-maven2jpp-newdepmap.xsl
Source3:        pom-maven2jpp-mapdeps.xsl
Source4:        commons-net-1.4.1-jpp-depmap.xml

# svn export -r '{2007-02-15}' http://svn.apache.org/repos/asf/jakarta/commons/proper/commons-build/trunk/ commons-build
# tar czf commons-build.tar.gz commons-build
Source5:        commons-build.tar.gz
Source6:        commons-net-1.4.1.pom

Patch0:         %{name}-crosslink.patch
Patch1:         %{short_name}-%{version}-project_xml.patch
Patch2:         %{short_name}-%{version}-project_properties.patch
BuildRequires:  jpackage-utils >= 0:1.7.2
BuildRequires:  ant >= 0:1.6
%if ! %{without_tests}
BuildRequires:  ant-junit >= 0:1.6
%endif
BuildRequires:  junit >= 3.8.1
BuildRequires:  java-javadoc
BuildRequires:  oro >= 2.0.8
%if %{with_maven}
BuildRequires:  maven >= 0:1.1
BuildRequires:  maven-plugins-base
BuildRequires:  maven-plugin-changes
BuildRequires:  maven-plugin-checkstyle
BuildRequires:  maven-plugin-jcoverage
BuildRequires:  maven-plugin-jdepend
BuildRequires:  maven-plugin-jxr
BuildRequires:  maven-plugin-license
BuildRequires:  maven-plugin-tasklist
BuildRequires:  maven-plugin-test
BuildRequires:  maven-plugin-xdoc

BuildRequires:  saxon
BuildRequires:  saxon-scripts
%endif
Requires:       oro >= 2.0.8
Requires:       java
%if ! %{gcj_support}
BuildArch:      noarch
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Provides:       %{short_name} = %{epoch}:%{version}-%{release}
Obsoletes:      %{short_name} < %{epoch}:%{version}-%{release}
Requires:       jpackage-utils >= 0:1.7.2
%if %{gcj_support}
BuildRequires:    java-gcj-compat-devel
Requires(post):   java-gcj-compat
Requires(postun): java-gcj-compat
%endif

%description
This is an Internet protocol suite Java library originally developed by
ORO, Inc.  This version supports Finger, Whois, TFTP, Telnet, POP3, FTP,
NNTP, SMTP, and some miscellaneous protocols like Time and Echo as well
as BSD R command support. The purpose of the library is to provide
fundamental protocol access, not higher-level abstractions. 

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

%description javadoc
Javadoc for %{name}.

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

%description manual
%{summary}.
%endif

%prep
cat <<EOT

                If you dont want to build with maven,
                give rpmbuild option '--without maven'

EOT

%setup -q -n %{short_name}-%{version}
gzip -dc %{SOURCE5} | tar xf -

%patch0 -b .sav
%patch1 -b .sav
%patch2 -b .sav
# remove all binary libs
find . -name "*.jar" -exec rm -f {} \;

%build
%if %{with_maven}
export DEPCAT=$(pwd)/commons-net-1.4.1-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} > commons-net-1.4.1-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

#        -Dmaven.test.failure.ignore=true \
maven -e \
        -Dmaven.repo.remote=file:/usr/share/maven/repository \
        -Dmaven.home.local=${MAVEN_HOME_LOCAL} \
        jar:jar javadoc:generate site
%else
mkdir -p target/lib
ln -s %{_javadir}/oro.jar target/lib
ln -s %{_javadir}/junit.jar target/lib

export CLASSPATH=%{_javadir}/oro.jar:%{_javadir}/junit.jar
%if %{without_tests}
ant -Dnoget=true -Dfinal.name=commons-net-%{version} \
  -Dj2se.api=%{_javadocdir}/java jar javadoc
%else
export OPT_JAR_LIST="ant/ant-junit junit"
# FIXME: Investigate test failures in Fedora
ant -Dnoget=true -Dfinal.name=commons-net-%{version} \
  -Dj2se.api=%{_javadocdir}/java jar test javadoc
%endif
%endif

%install
rm -rf $RPM_BUILD_ROOT

# jars
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}
%add_to_maven_depmap %{short_name} %{short_name} %{version} JPP %{short_name}

install -m 644 target/%{short_name}-%{version}.jar \
    $RPM_BUILD_ROOT%{_javadir}/%{name}-%{version}.jar

(cd $RPM_BUILD_ROOT%{_javadir} && 
    for jar in *-%{version}*; 
        do ln -sf ${jar} `echo $jar| sed  "s|jakarta-||g"`; 
    done
)

(cd $RPM_BUILD_ROOT%{_javadir} && 
    for jar in *-%{version}*; 
        do ln -sf ${jar} `echo $jar| sed  "s|-%{version}||g"`; 
    done
)

# pom
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/maven2/poms
install -pm 644 %{SOURCE6} \
    $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP-%{name}.pom

# javadoc
install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
%if %{with_maven}
cp -pr target/docs/apidocs/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
%else
cp -pr dist/docs/api/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
%endif
ln -s %{name}-%{version} $RPM_BUILD_ROOT%{_javadocdir}/%{name} # ghost symlink
rm -rf target/docs/apidocs
# manual
install -d -m 755 $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
cp LICENSE.txt $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
%if %{with_maven}
install -d -m 755 $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}/site
cp -pr target/docs/* $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}/site
%endif

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

%clean
rm -rf $RPM_BUILD_ROOT

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

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

%files
%defattr(0644,root,root,0755)
%doc %{_docdir}/%{name}-%{version}/LICENSE.txt
%{_javadir}/*
%{_datadir}/maven2/poms/*
%{_mavendepmapfragdir}
%if %{gcj_support}
%attr(-,root,root) %{_libdir}/gcj/%{name}
%endif

%files javadoc
%defattr(0644,root,root,0755)
%doc %{_javadocdir}/*

%if %{with_maven}
%files manual
%defattr(0644,root,root,0755)
%{_docdir}/%{name}-%{version}
%endif

%changelog
* Tue Jan 22 2008 Permaine Cheung <pcheung@redhat.com> - 0:1.4.1-4jpp.1
- Merge with upstream

* Fri Aug 31 2007 Ralph Apel <r.apel at r-apel.de> - 0:1.4.1-4jpp
- Add oro Requires
- Add pom and depmap frags
- Make Vendor, Distribution based on macro

* Thu May 03 2007 Ralph Apel <r.apel at r-apel.de> - 0:1.4.1-3jpp
- Fix project_properties.patch to meet new plugins
- Add maven-plugin-* BRs

* Thu Feb 15 2007 Deepak Bhole <dbhole@redhat.com> - 0:1.4.1-2jpp.1
- Fix per Fedora spec
- Disable tests as a bunch of them currently fail on Fedora

* Mon Feb 12 2007 Ralph Apel <r.apel at r-apel.de> - 0:1.4.1-2jpp
- Add gcj_support
- Tests optional when building without maven

* Mon May 08 2006 Ralph Apel <r.apel at r-apel.de> - 0:1.4.1-1jpp
- Upgrade to 1.4.1
- First JPP-1.7 release
- Add -manual subpackage
- Build with maven by default
- Optionally build with straight ant

* Sat Nov 13 2004 Ville Skyttä <scop at jpackage.org> - 0:1.2.2-3jpp
- BuildRequire ant-junit, thanks to Nicolas Mailhot for the catch.
- Crosslink with local J2SE API docs, remove extra api/ from javadoc dir.

* Sun Aug 23 2004 Randy Watler <rwatler at finali.com> - 0:1.2.2-2jpp
- Rebuild with ant-1.6.2

* Sun Jun 27 2004 Kaj J. Niemi <kajtzu@fi.basen.net> 0:1.2.2-1jpp
- Update to 1.2.2

* Tue Oct 28 2003 Henri Gomez <hgomez@users.sourceforge.net> 0:1.1.0-1jpp
- commons-net 1.1.0

* Tue May 06 2003 David Walluck <david@anti-microsoft.org> 0:1.0.0-3jpp
- update for JPackage 1.5

* Thu Feb 27 2003 Henri Gomez <hgomez@users.sourceforge.net> 1.0.0-2jpp
- fix ASF license and add packager tag

* Mon Feb 24 2003 Henri Gomez <hgomez@users.sourceforge.net> 1.0.0-1jpp
- 1.0.0
- initial release