File classworlds.spec of Package classworlds

#
# spec file for package classworlds
#
# 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}}
%bcond_with maven

Name:           classworlds
Version:        1.1
Release:        0
Summary:        Classworlds Classloader Framework
License:        BSD-3-Clause
Group:          Development/Libraries/Java
Url:            http://classworlds.codehaus.org/
Source0:        classworlds-1.1-src.tar.bz2
# svn export http://svn.codehaus.org/classworlds/tags/CLASSWORLDS_1_1/classworlds/ classworlds-1.1
Source1:        classworlds-1.1-build.xml
Source2:        http://repo1.maven.org/maven2/%{name}/%{name}/%{version}/%{name}-%{version}.pom
Patch0:         classworlds-1.1-project_xml.patch
#rap#Patch1:         classworlds-1.1-project_properties.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Requires(post):    javapackages-tools
Requires(postun):  javapackages-tools
BuildRequires:  ant >= 1.6
%if %with maven
BuildRequires:  maven >= 1.1
BuildRequires:  saxon
BuildRequires:  saxon-scripts
%endif
BuildRequires:  junit
BuildRequires:  xerces-j2
BuildRequires:  xml-commons-apis
Requires:       xerces-j2
Requires:       xml-commons-apis

%description
Classworlds is a framework for container developers 
who require complex manipulation of Java's ClassLoaders.
Java's native ClassLoader mechanims and classes can cause 
much headache and confusion for certain types of 
application developers. Projects which involve dynamic 
loading of components or otherwise represent a 'container' 
can benefit from the classloading control provided by 
classworlds. 

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

%description    javadoc
Classworlds is a framework for container developers 
who require complex manipulation of Java's ClassLoaders.
Java's native ClassLoader mechanims and classes can cause 
much headache and confusion for certain types of 
application developers. Projects which involve dynamic 
loading of components or otherwise represent a 'container' 
can benefit from the classloading control provided by 
classworlds. 



%prep
%setup -q 
find -name "*.jar" | xargs rm
cp -p %{SOURCE1} build.xml
%patch0 -p0

%build
%if %with maven
pushd lib
ln -sf $(build-classpath xml-commons-apis) xmlApis-2.0.2.jar
ln -sf $(build-classpath ant) jakarta-ant-1.5.jar
ln -sf $(build-classpath maven) maven.jar
popd
maven \
         -Dmaven.repo.remote=file:/usr/share/maven/repository \
         -Dmaven.home.local=$(pwd)/.maven \
         jar javadoc xdoc:transform classworlds:build-boot-jar
%else
export CLASSPATH=target/classes:target/test-classes
export OPT_JAR_LIST=:
ant -Dant.build.javac.source=1.5 -Dant.build.javac.target=1.5 \
    -Dbuild.sysclasspath=only jar javadoc
%endif

%install
install -Dpm 644 target/%{name}-%{version}.jar \
  $RPM_BUILD_ROOT%{_javadir}/%{name}-%{version}.jar
%if %with maven
install -Dpm 644 target/%{name}-boot-%{version}.jar \
  $RPM_BUILD_ROOT%{_javadir}/%{name}-boot-%{version}.jar
%endif
(cd $RPM_BUILD_ROOT%{_javadir} && for jar in *-%{version}.jar; do ln -sf ${jar} `echo $jar| sed  "s|-%{version}||g"`; done)

# POM and depmap
install -d -m 755 $RPM_BUILD_ROOT%{_mavenpomdir}
install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mavenpomdir}/JPP-%{name}.pom
%add_maven_depmap

# javadocs
install -dm 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -pr target/docs/apidocs/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
ln -s %{name}-%{version} $RPM_BUILD_ROOT%{_javadocdir}/%{name}
# FIXME: (dwalluck): breaks -bi --short-circuit
rm -rf target/docs/apidocs
# docs
%if %with maven
cp -pr target/docs/* $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
%endif

%files
%defattr(0644,root,root,0755)
%doc LICENSE.txt
%{_javadir}/*.jar
%{_mavenpomdir}/*
%config %{_mavendepmapfragdir}/*

%files javadoc
%defattr(0644,root,root,0755)
%{_javadocdir}/%{name}-%{version}
%{_javadocdir}/%{name}
#% if %with maven
#% files manual
#% defattr(0644,root,root,0755)
#% doc %{_docdir}/%{name}-%{version}
#% endif

%changelog