LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File xml-commons-apis-bootstrap.spec of Package xml-commons-apis-bootstrap (Project Java:packages)

# vim:fdm=marker:foldmarker=#>>>,#<<<:foldcolumn=6:
#
# spec file for package xml-commons-apis-bootstrap
#
# Copyright (c) 2012 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       xml_commons_version 1.0.b2
%define       real_name xml-commons
%define       apis_jar %{real_name}-apis-bootstrap
%define       which_jar %{real_name}-which-bootstrap
%define       resolver_jar %{real_name}-resolver-bootstrap

Name:           xml-commons-apis-bootstrap
Version:        1.3.04
Release:        0
Summary:        Common code for XML projects - bootstrapping package
License:        Apache-2.0
Group:          Development/Libraries/Java
Url:            http://xml.apache.org/commons/
# svn export http://svn.apache.org/repos/asf/xml/commons/tags/xml-commons-1_0_b2/
Source0:        xml-commons-1.0.b2.tar.bz2
# svn export http://svn.apache.org/repos/asf/xml/commons/tags/xml-commons-external-1_2_04/
Source1:        xml-commons-external-1.2.04.tar.bz2
# svn export http://svn.apache.org/repos/asf/xml/commons/tags/xml-commons-external-1_3_04/
Source2:        xml-commons-external-1.3.04.tar.bz2
# svn export http://svn.apache.org/repos/asf/xml/commons/tags/xml-commons-resolver-1_1_b1/
Source3:        xml-commons-resolver-1.1.b1.tar.bz2
Patch0:         %{real_name}-external-1.3-build_xml.patch
Patch1:         %{real_name}-resolver-crosslink.patch
Patch2:         %{real_name}-resolver-1.1-build_xml.patch
Patch3:         %{real_name}-enum.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Provides:       xml-apis
#!BuildIgnore:  antlr antlr-java
BuildRequires:  antlr-bootstrap
BuildRequires:  java-1_5_0-gcj-compat-devel
#!BuildIgnore:  java-1_6_0-openjdk java-1_6_0-openjdk-devel
#!BuildIgnore:  java-1_7_0-openjdk java-1_7_0-openjdk-devel
BuildRequires:  fastjar
BuildRequires:  update-alternatives

%description
This is xml-apis from the java-bootrapping-tools package. DO NOT
INSTALL ... THIS IS JUST FOR PACKAGING & BOOTSTRAPPING JAVA PURPOSES!!

%package -n xml-commons-which-bootstrap
Summary:        Which subproject of xml-commons
Group:          Development/Libraries/Java
Url:            http://xml.apache.org/commons/

%description -n xml-commons-which-bootstrap
This is xml-which from the java-bootrapping-tools package. DO NOT
INSTALL ... THIS IS JUST FOR PACKAGING & BOOTSTRAPPING JAVA PURPOSES!!

%package -n xml-commons-resolver-bootstrap
Summary:        Resolver subproject of xml-commons
Group:          Development/Libraries/Java
Url:            http://xml.apache.org/commons/

%description -n xml-commons-resolver-bootstrap
This is xml-resolver from the java-bootrapping-tools package. DO NOT
INSTALL ... THIS IS JUST FOR PACKAGING & BOOTSTRAPPING JAVA PURPOSES!!


%prep
# To make patches unchanged
%setup -q -T -c
%setup -q -T -D -a 0
%setup -q -T -D -a 1
%setup -q -T -D -a 2
%setup -q -T -D -a 3

%patch1 -b .sav
%patch2 -b .sav
%patch3 -b .sav
pushd xml-commons-external-1_3_*
%patch0 -b .sav
popd

%build 
#>>> some useful functions ... used throughout bootstrap packages

#>>> delete binary file and files not needed
function delBinaryFiles() {
  set +x
  echo deleting binary files ...
  for file in `find . -name "*.class" -o -name "*.jar" -o -name "*DELETED-BY-PACKAGER*"` 
  do 
    rm -rf $file
  done
  set -x
}
#<<<

#>>> make a string with all jar files found in target folder that can be used for a classpath string
# string is saved in JAR_CLASSPATH
function mkTargetClasspath() {
  set +x
  JAR_CLASSPATH=""
  for file in `find %{_javadir} -name "*.jar"`
  do
    JAR_CLASSPATH=$file:$JAR_CLASSPATH
  done
  set -x
}
#<<<

#>>> compiles all *.java file in the current directory tree
# uses mkTargetClasspath for CLASSPATH  variable
# uses LIB_GCJ for CLASSPATH
function compileFiles() {
  COMPILE_CLASSPATH_PATH=.:${JAR_CLASSPATH}
  echo using: $COMPILER_COMMAND $COMPILE_CLASSPATH_PATH $$file
  for file in `find . -name "*.java"`
  do
    echo -e "$COMPILER_COMMAND $COMPILE_CLASSPATH_PATH $file ... \c"
    $COMPILER_COMMAND $COMPILE_CLASSPATH_PATH $file
    # check for errors
    if [ $? != 0 ]
    then
      echo ERROR
      exit 1;
    fi
    echo done
  done
}
#<<<

#>>> make jar archive
# PARAM#1: name of jar archive (without .jar suffix)
# uses $TARGET_DIR to move created jar to
function mkJar() {
  find  -name "version.txt" -or -name "*.class" -or -name "*.properties" -or -name "*.rsc" -or -name "*manifest*" |\
    xargs /usr/bin/fastjar -m manifest.* -cf ${1}.jar ;
  mv ${1}.jar $TARGET_DIR
}
#<<<

#<<< end functions

# variables:
COMPILER_COMMAND="javac -C -ftarget=1.4 -classpath "
TARGET_DIR=`pwd`
CLASSPATH_ORIG="$CLASSPATH"
LIB_GCJ="`ls %{_javadir}/libgcj-*.jar`"

delBinaryFiles
#>>> xml-apis and xml-which
# compile external files

pushd xml-commons-1_0_b2
cd java/external/src
mkTargetClasspath
compileFiles
mkJar %{apis_jar}
delBinaryFiles

# compile the rest
cd ../../src/
# remove resolver
rm -rf org/apache/xml/
mkTargetClasspath
compileFiles
mkJar %{which_jar}
delBinaryFiles
popd

pushd xml-commons-resolver-1_1_b1
mkTargetClasspath
export JAR_CLASSPATH=$JAR_CLASSPATH:${TARGET_DIR}/%{apis_jar}.jar:${TARGET_DIR}/%{which_jar}.jar
#compileFiles
pushd java/src/
$COMPILER_COMMAND $JAR_CLASSPATH `find . -name *.java`
rm manifest.which
mkJar %{resolver_jar}
delBinaryFiles
#<<< xml-commons end
popd
popd
#<<< build end

%install
#>>> % install
mkdir -p $RPM_BUILD_ROOT/%{_javadir}
cp %{apis_jar}.jar $RPM_BUILD_ROOT/%{_javadir}
cp %{which_jar}.jar $RPM_BUILD_ROOT/%{_javadir}
cp %{resolver_jar}.jar $RPM_BUILD_ROOT/%{_javadir}
#<<< install end

%clean
rm -rf $RPM_BUILD_ROOT 
#>>> files

%files 
%defattr(-,root,root)
%doc xml-commons-1_0_b2/LICENSE.txt 
%{_javadir}/%{apis_jar}.jar

%files -n xml-commons-which-bootstrap
%defattr(-,root,root)   
%doc xml-commons-1_0_b2/LICENSE.txt 
%{_javadir}/%{which_jar}.jar

%files -n xml-commons-resolver-bootstrap
%defattr(-,root,root)   
%doc xml-commons-1_0_b2/LICENSE.txt 
%{_javadir}/%{resolver_jar}.jar
#<<<

%changelog