File qdox.spec of Package qdox

#
# spec file for package qdox
#
# Copyright (c) 2013 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.12.1
Release:        0
Summary:        Extract class/interface/method definitions from sources
License:        Apache-2.0
Group:          Development/Libraries/Java
Url:            http://qdox.codehaus.org/
# svn checkout https://svn.codehaus.org/qdox/tags/qdox-1.12.1 qdox-1.12.1
# tar --exclude-vcs -cJf qdox-1.12.1.tar.xz qdox-1.12.1
Source0:        qdox-%{version}.tar.xz
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
BuildRequires:  gpg2
BuildRequires:  javapackages-tools
%if %with maven
BuildRequires:  jmock >= 1.0
BuildRequires:  maven >= 1.1
BuildRequires:  maven-plugin-license
BuildRequires:  maven-plugin-test
BuildRequires:  maven-plugin-xdoc
BuildRequires:  maven-plugins-base
BuildRequires:  mockobjects >= 0.09
BuildRequires:  saxon9
BuildRequires:  saxon9-scripts
%endif
BuildRequires:  ant >= 1.6
BuildRequires:  ant-junit >= 1.6
BuildRequires:  byaccj
BuildRequires:  java-cup
BuildRequires:  jflex
BuildRequires:  jmock
BuildRequires:  junit >= 3.8.1
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
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
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
# % 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}/saxon9 project.xml %{SOURCE1} >> $DEPCAT
    popd
done
echo >> $DEPCAT
echo '</depset>' >> $DEPCAT
%{_bindir}/saxon9 $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}/saxon9 -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)
%{java} JFlex.Main \
    -d src/java/com/thoughtworks/qdox/parser/impl \
    --skel src/grammar/skeleton.inner \
    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 -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
openSUSE Build Service is sponsored by