File qdox.spec of Package qdox

#
# spec file for package qdox (Version 1.6.1)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%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}}
%define _without_maven 1
%bcond_with maven
# If you want repolib package to be built,
# issue the following: 'rpmbuild --with repolib'
%define _with_repolib 1
%define with_repolib %{?_with_repolib:1}%{!?_with_repolib:0}
%define without_repolib %{!?_with_repolib:1}%{?_with_repolib:0}
%define repodir %{_javadir}/repository.jboss.com/qdox/1.6.1-brew
%define repodirlib %{repodir}/lib
%define repodirsrc %{repodir}/src
%define section free

Name:           qdox
Version:        1.6.1
Release:        2
Summary:        Extract class/interface/method definitions from sources
License:        The Apache Software License
Url:            http://qdox.codehaus.org/
Group:          Development/Libraries/Java
# svn co https://svn.codehaus.org/qdox/tags/QDOX_1_6_1/qdox
# tar czvf qdox-1.6.1-src.tar.gz qdox
Source0:        qdox-%{version}-src.tar.bz2
Source1:        pom-maven2jpp-depcat.xsl
Source2:        pom-maven2jpp-newdepmap.xsl
Source3:        pom-maven2jpp-mapdeps.xsl
Source4:        qdox-1.6-jpp-depmap.xml
Source5:        qdox-LocatedDef.java
Source6:        qdox-build.xml
Source7:        qdox-component-info.xml
Patch0:         qdox-1.6.1-byaccj.patch
Patch1:         qdox-1.6.1-jflex.patch
Patch2:         qdox-1.6.1-test.patch
BuildRequires:  jpackage-utils >= 1.6
%if %with maven
BuildRequires:  maven >= 1.1
BuildRequires:  maven-plugins-base
BuildRequires:  maven-plugin-license
BuildRequires:  maven-plugin-test
BuildRequires:  maven-plugin-xdoc
BuildRequires:  saxon
BuildRequires:  saxon-scripts
BuildRequires:  jmock >= 1.0
BuildRequires:  mockobjects >= 0.09
%endif
BuildRequires:  ant >= 1.6
BuildRequires:  ant-junit >= 1.6
BuildRequires:  junit >= 3.8.1
BuildRequires:  byaccj
BuildRequires:  java-cup
BuildRequires:  jflex
BuildRequires:  jmock
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
QDox is a high speed, small footprint parser for extracting
class/interface/method definitions from source files complete with
JavaDoc @tags. It is designed to be used by active code generators or
documentation tools.



%if %{with_repolib}

%package repolib
License:        The Apache Software License
Summary:        Artifacts to be uploaded to a repository library
Group:          Development/Libraries/Java

%description repolib
QDox is a high speed, small footprint parser for extracting
class/interface/method definitions from source files complete with
JavaDoc @tags. It is designed to be used by active code generators or
documentation tools.



%endif

%package javadoc
License:        The Apache Software License
Summary:        Extract class/interface/method definitions from sources
Group:          Development/Libraries/Java

%description javadoc
QDox is a high speed, small footprint parser for extracting
class/interface/method definitions from source files complete with
JavaDoc @tags. It is designed to be used by active code generators or
documentation tools.



%prep
%setup -q -n %{name}
chmod -Rf a+rX,u+w,g-w,o-w bootstrap
rm -r bootstrap
%patch0 -p1
%patch1 -p1
%patch2 -p1
cp -p %{SOURCE5} src/java/com/thoughtworks/qdox/parser/structs/LocatedDef.java 
sed -e "s/@VERSION@/%{version}/g" %{SOURCE6} > build.xml
%if %{with_repolib}
tag=`echo %{name}-%{version}-%{release} | sed 's|\.|_|g'`
sed -i "s/@TAG@/$tag/g" %{SOURCE7}
%endif

%build
%if %with maven
export DEPCAT=$(pwd)/qdox-1.6-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)
    %{_bindir}/saxon project.xml %{SOURCE1} >> $DEPCAT
    popd
done
echo >> $DEPCAT
echo '</depset>' >> $DEPCAT
%{_bindir}/saxon $DEPCAT %{SOURCE2} > qdox-1.6-depmap.new.xml
for p in $(find . -name project.xml); do
    pushd $(dirname $p)
    cp project.xml project.xml.orig
    %{_bindir}/saxon -o project.xml project.xml.orig %{SOURCE3} map=%{SOURCE4}
    popd
done
export MAVEN_HOME_LOCAL=$(pwd)/.maven
export CLASSPATH=$(build-classpath junit)
maven \
        -Dmaven.repo.remote=file:/usr/share/maven-1.0/repository \
        -Dmaven.home.local=$MAVEN_HOME_LOCAL \
        -Dqdox.byaccj.executable=byaccj \
        jar javadoc
%else
export OPT_JAR_LIST="junit ant/ant-junit"
mkdir -p target/src/java/com/thoughtworks/qdox/parser/impl
export CLASSPATH=`pwd`/target/classes:`pwd`/target/test-classes:$(build-classpath java-cup jflex jmock junit)
%{java} JFlex.Main \
    -d src/java/com/thoughtworks/qdox/parser/impl \
    src/grammar/lexer.flex
pushd target
%{_bindir}/byaccj \
    -Jnorun \
    -Jnoconstruct \
    -Jclass=Parser \
    -Jsemantic=Value \
    -Jpackage=com.thoughtworks.qdox.parser.impl \
    ../src/grammar/parser.y
popd
mv target/Parser.java src/java/com/thoughtworks/qdox/parser/impl
ant -Dant.build.javac.source=1.5 -Dant.build.javac.target=1.5 -Dbuild.sysclasspath=only jar javadoc
%endif

%install
# jars
mkdir -p $RPM_BUILD_ROOT%{_javadir}
cp -p target/%{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 target/site/apidocs/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
ln -s %{name}-%{version} $RPM_BUILD_ROOT%{_javadocdir}/%{name}
%if %{with_repolib}
        install -d -m 755 $RPM_BUILD_ROOT%{repodir}
        install -d -m 755 $RPM_BUILD_ROOT%{repodirlib}
        install -p -m 644 %{SOURCE7} $RPM_BUILD_ROOT%{repodir}/component-info.xml
        install -d -m 755 $RPM_BUILD_ROOT%{repodirsrc}
        install -p -m 644 %{SOURCE0} $RPM_BUILD_ROOT%{repodirsrc}
        cp -p $RPM_BUILD_ROOT%{_javadir}/qdox.jar $RPM_BUILD_ROOT%{repodirlib}
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(0644,root,root,0755)
%doc LICENSE.txt
%{_javadir}/%{name}.jar
%{_javadir}/%{name}-%{version}.jar

%files javadoc
%defattr(0644,root,root,0755)
%{_javadocdir}/%{name}-%{version}
%{_javadocdir}/%{name}
%if %{with_repolib}

%files repolib
%defattr(0644,root,root,0755)
%{repodir}
%dir %{_datadir}/java/repository.jboss.com/%{name}
%dir %{_datadir}/java/repository.jboss.com/
%endif

%changelog
* Tue May 05 2009 mvyskocil@suse.cz
- Initial build in SUSE. Version 1.6.1 from jpp 5.0