Package cobertura: Specfile

Packager: Igor Vlasenko <viy@altlinux.ru>
BuildRequires: /proc
BuildRequires: jpackage-compat
# Copyright (c) 2000-2009, 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 with()          %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
%define without()       %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
%define bcond_with()    %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
%define bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}

#def_with gcj_support
%bcond_with gcj_support

%if %with gcj_support
%define gcj_support 0
%else
%define gcj_support 0
%endif


Name:           cobertura
Version:        1.9.3
Release:        alt1_2jpp6
Epoch:          0
Summary:        Free Java tool that calculates the percentage of code accessed by tests
Group:          Development/Java
License:        GPLv2+
URL:            http://cobertura.sourceforge.net/
Source0:        http://downloads.sourceforge.net/cobertura/cobertura-1.9.3-src.tar.gz
Source1:        %{name}-%{version}.pom
Source2:        %{name}-runtime-%{version}.pom
Source3:        cobertura-check.sh
Source4:        cobertura-instrument.sh
Source5:        cobertura-merge.sh
Source6:        cobertura-report.sh
Requires(post): jpackage-utils >= 0:1.7.3
Requires(postun): jpackage-utils >= 0:1.7.3
Requires: ant >= 0:1.6.5
Requires: jpackage-utils >= 0:1.7.3
Requires: jakarta-oro
Requires: junit
Requires: log4j
Requires: objectweb-asm >= 0:3.0
%if 0
Requires: servlet_2_5_api
%endif
BuildRequires: ant >= 0:1.6.5
BuildRequires: ant-junit
BuildRequires: ant-trax
BuildRequires: jpackage-utils >= 0:1.7.3
BuildRequires: jakarta-oro
#BuildRequires:  groovy15
BuildRequires: jaxen
BuildRequires: jdom
BuildRequires: junit
BuildRequires: log4j
BuildRequires: objectweb-asm >= 0:3.0
BuildRequires: servlet_2_5_api
%if %{gcj_support}
BuildRequires: java-gcj-compat-devel
%else
BuildArch:      noarch
%endif
Source44: import.info

%description
Cobertura is a free Java tool that calculates the percentage of code 
accessed by tests. It can be used to identify which parts of your 
Java program are lacking test coverage. It is based on jcoverage.

Features

    * Can be executed from ant or from the command line.
    * Instruments Java bytecode after it has been compiled.
    * Can generate reports in HTML or XML.
    * Shows percent of lines coveraged and branches coveraged for each
      class, package, and for the overall project.
    * Shows the McCabe cyclomatic code complexity of each class, and
      the average cyclomatic code complexity for each package, and for
      the overall product.
    * Can sort HTML results by class name, percent of lines covered,
      percent of branches covered, etc. And can sort in ascending or
      decending order.

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

%description    javadoc
Javadoc for %{name}.

%prep
%setup -q
%{_bindir}/find . -type f -name '*.jar' | %{_bindir}/xargs -t %{__rm}
%{__perl} -pi -e 's/\r$//g' ChangeLog COPYING COPYRIGHT README

pushd antLibrary/common
# FIXME: taskdef A class needed by class org.codehaus.groovy.ant.Groovyc cannot be found: groovyjarjarcommonscli/ParseException
#%{__ln_s} $(build-classpath groovy15-all) groovy
popd

pushd lib
%{__ln_s} $(build-classpath jakarta-oro)
%{__ln_s} $(build-classpath junit)
%{__ln_s} $(build-classpath log4j)
%{__ln_s} $(build-classpath objectweb-asm/asm)
%{__ln_s} $(build-classpath objectweb-asm/asm-tree)
%{__ln_s} $(build-classpath servlet_2_5_api) servlet-api.jar
popd

%build
export CLASSPATH=$(build-classpath ant)
export OPT_JAR_LIST=:
#export OPT_JAR_LIST=`%{__cat} %{_sysconfdir}/ant.d/{junit,trax}`
ant -Dant.build.javac.source=1.5 -Dant.build.javac.target=1.5 -Djetty.dir=. clean compile jar javadoc

%install

# jar
%{__mkdir_p} %{buildroot}%{_javadir}
%{__cp} -p %{name}.jar %{buildroot}%{_javadir}/%{name}-%{version}.jar
(cd %{buildroot}%{_javadir} && for jar in *-%{version}*; do \
%{__ln_s} ${jar} ${jar/-%{version}/}; done)
%add_to_maven_depmap cobertura cobertura %{version} JPP %{name}
%add_to_maven_depmap cobertura cobertura-runtime %{version} JPP %{name}
%add_to_maven_depmap net.sourceforge.cobertura cobertura %{version} JPP %{name}
%add_to_maven_depmap net.sourceforge.cobertura cobertura-runtime %{version} JPP %{name}

# pom
%{__mkdir_p} %{buildroot}%{_datadir}/maven2/poms
%{__cp} -p %{SOURCE1} %{buildroot}%{_datadir}/maven2/poms/JPP-%{name}.pom
%{__cp} -p %{SOURCE2} %{buildroot}%{_datadir}/maven2/poms/JPP-%{name}-runtime.pom

%{__mkdir_p}  %{buildroot}%{_sysconfdir}/ant.d
%__cat > %{buildroot}%{_sysconfdir}/ant.d/%{name} << EOF
ant cobertura junit log4j oro xerces-j2
EOF

# bin
%{__mkdir_p} %{buildroot}%{_bindir}
%{__install} -p -m 755 %{SOURCE3} %{buildroot}%{_bindir}/%{name}-check
%{__install} -p -m 755 %{SOURCE4} %{buildroot}%{_bindir}/%{name}-instrument
%{__install} -p -m 755 %{SOURCE5} %{buildroot}%{_bindir}/%{name}-merge
%{__install} -p -m 755 %{SOURCE6} %{buildroot}%{_bindir}/%{name}-report

# javadoc
%{__mkdir_p} %{buildroot}%{_javadocdir}/%{name}-%{version}
%{__cp} -pr build/api/* %{buildroot}%{_javadocdir}/%{name}-%{version}
(cd %{buildroot}%{_javadocdir} && %{__ln_s} %{name}-%{version} %{name})

%if %{gcj_support}
%{_bindir}/aot-compile-rpm
%endif

mkdir -p $RPM_BUILD_ROOT`dirname /etc/cobertura-check.conf`
touch $RPM_BUILD_ROOT/etc/cobertura-check.conf

mkdir -p $RPM_BUILD_ROOT`dirname /etc/cobertura-instrument.conf`
touch $RPM_BUILD_ROOT/etc/cobertura-instrument.conf

mkdir -p $RPM_BUILD_ROOT`dirname /etc/cobertura-merge.conf`
touch $RPM_BUILD_ROOT/etc/cobertura-merge.conf

mkdir -p $RPM_BUILD_ROOT`dirname /etc/cobertura-report.conf`
touch $RPM_BUILD_ROOT/etc/cobertura-report.conf

%files
%doc ChangeLog COPYING COPYRIGHT README
%attr(0755,root,root) %{_bindir}/%{name}-check
%attr(0755,root,root) %{_bindir}/%{name}-instrument
%attr(0755,root,root) %{_bindir}/%{name}-merge
%attr(0755,root,root) %{_bindir}/%{name}-report
%{_javadir}/%{name}-%{version}.jar
%{_javadir}/%{name}.jar
%config(noreplace) %{_sysconfdir}/ant.d/%{name}
%{_datadir}/maven2/poms/JPP-%{name}.pom
%{_datadir}/maven2/poms/JPP-%{name}-runtime.pom
%{_mavendepmapfragdir}/%{name}
%if %{gcj_support}
%dir %{_libdir}/gcj/%{name}
%{_libdir}/gcj/%{name}/%{name}-%{version}.jar.*
%endif
%config(noreplace,missingok) /etc/cobertura-check.conf
%config(noreplace,missingok) /etc/cobertura-instrument.conf
%config(noreplace,missingok) /etc/cobertura-merge.conf
%config(noreplace,missingok) /etc/cobertura-report.conf

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

%changelog
* Fri Nov 26 2010 Igor Vlasenko <viy@altlinux.ru> 0:1.9.3-alt1_2jpp6
- new version

* Sat Mar 06 2010 Igor Vlasenko <viy@altlinux.ru> 0:1.9-alt1_11jpp5
- new jpp release

* Sat Feb 21 2009 Igor Vlasenko <viy@altlinux.ru> 0:1.9-alt1_10jpp5
- new version

* Thu Nov 15 2007 Igor Vlasenko <viy@altlinux.ru> 0:1.9-alt1_2jpp1.7
- converted from JPackage by jppimport script