File jedit.spec of Package jedit

# spec file for package jedit (Version 4.3.2)
# Copyright (c) 2010 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

# norootforbuild
# icecream 0

%define section		free

Name:           jedit
Version:        4.3.2
Release:        1
Summary:        Programmer's Text Editor Written in Java
License:        GPLv2+
Group:          Productivity/Editors/Other
Source1:        %{name}-16.png
Source2:        %{name}-32.png
Source3:        %{name}-48.png
Patch0:         %{name}-installer.patch
#use patches from debian, because they document the changes between original
#bsh and the jedit's version
Patch1:         00bsh-jedit.patch
Patch2:         01bsh-jedit-asm.patch
Patch3:         02build.xml.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
BuildRequires:  java-devel
BuildRequires:  aelfred
BuildRequires:  ant
BuildRequires:  ant-nodeps
#BuildRequires:  bsh2
#BuildRequires:  bsh2-classgen
#BuildRequires:  bsh2-javadoc
BuildRequires:  bsh2-src
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  gnu-regexp
BuildRequires:  iso_ent
BuildRequires:  libxslt
BuildRequires:  openjade
BuildRequires:  xml-commons-apis
BuildRequires:  fop
#BuildRequires:  xorg-x11
#BuildRequires:  xorg-x11-devel
BuildRequires:  fdupes
Requires:       aelfred
Requires:       asm
#Requires:       bsh2
#Requires:       bsh2-classgen
Requires:       gnu-regexp
Requires:       jpackage-utils >= 1.5
Obsoletes:      %{name}-rhmenu < %{version}
Obsoletes:      antlr-jedit < %{version}
Provides:       %{name}-rhmenu = %{version}
Provides:       antlr-jedit = %{version}

jEdit is a cross-platform programmer's text editor written in Java.

Some of jEdit's features include:

* Built-in macro language (BeanShell)

* Extensible plug-in architecture with more than 80 plug-ins

* Plug-ins can be downloaded and installed from within jEdit using
   the plug-in manager feature

* Syntax highlighting for more than 80 languages

* Supports a large number of character encodings including UTF8 and

* Autoindenting of source code

* Folding (indent and marker based)

* Word wrap

* Unlimited undo and redo

* Highly configurable and customizable

* Every other feature, both basic and advanced, that you would expect
to find in a text editor

%package javadoc
License:        GPLv2+
PreReq:         coreutils
Summary:        Programmer's text editor written in Java (Documentation)
Group:          Productivity/Editors/Other

%description javadoc
Javadoc for jedit.

#%setup -q -n jEdit
%setup -q -D -n jEdit
# the similar apporach to Debian's package
# unpack bsh and then patch it
(%{__mkdir} bsh; cd bsh; %{__tar} -xf %{_usrsrc}/bsh2-src/bsh2.tar.bz2 )
# this will fail on each rebuild of bsh2, so do it by sed
%{__sed} -i 's/\(.*\)String VERSION = "2.0.0.b5.*/\1String VERSION = "2.0.0.b4-jedit";/' bsh/src/bsh/
%patch0 -p1 -b.installer
%patch1 -p1 -b .bsh
%patch2 -p1 -b .bsh-asm
%patch3 -p2 -b .bsh-build.xml
# remove all included external sources
%__rm -rf com
# remove all binary libs
#find . -name "*.jar" -exec rm -f {} \;

export CLASSPATH=$(build-classpath aelfred asm gnu.regexp)
#export CLASSPATH=$(build-classpath aelfred gnu.regexp)
# compress jedit.jar
%__perl -p -i -e 's|compress="false"|compress="true"|' build.xml
%__perl -p -i -e 's|app.version=.*|app.version=%{version}-%{release}|' installer/install.props
DOCBOOK_XSL=`rpm -ql docbook-xsl-stylesheets | %__grep /html/chunk.xsl \
| %__sed 's|/html/chunk.xsl||'`
if [ -z $DOCBOOK_XSL ]; then
  echo "Unable to find docbook xsl directory"
  exit 1
if [ -z "$SGML_CATALOG_FILES" -a -e %{_sysconfdir}/sgml/catalog ] ; then
  export SGML_CATALOG_FILES=%{_sysconfdir}/sgml/catalog
cat <<EOF >
%ant \
  build docs-html
# Build QuickNotepad.jar
(cd jars/QuickNotepad && %ant)

# FIXME: crosslink with gnu.regexp and bsh2 when they have non-versioned dirs
%ant -Djava.javadoc=%{_javadocdir}/java \
     -Daelfred.javadoc=%{_javadocdir}/aelfred \
     -Dasm.javadoc=%{_javadocdir}/asm \
     -Dbsh2.javadoc=%{_javadocdir}/bsh2 \
     -Dgnu.regexp.javadoc=%{_javadocdir}/bsh2 \

# dirs
%{__install} -d -m 0755 %{buildroot}%{_bindir}
%{__install} -d -m 0755 %{buildroot}/%{_datadir}/%{name}
%{__install} -d -m 0755 %{buildroot}/%{_javadocdir}/%{name}
%{__install} -d -m 0755 %{buildroot}/%{_mandir}/man1/

# jar
%{__install} -d -m 0755 %{buildroot}%{_javadir}
%{__cp} -a build/%{name}.jar %{buildroot}%{_javadir}/%{name}-%{version}.jar
(cd %{buildroot}%{_javadir} && for jar in *-%{version}*; do %{__ln_s} ${jar} ${jar/-%{version}/}; done) || true
(cd %{buildroot}%{_datadir}/%{name} && %{__ln_s} %{_javadir}/%{name}.jar %{name}.jar) || true

# the rest files
%{__cp} -pr build/{doc,macros,modes,properties,startup} %{buildroot}/%{_datadir}/%{name}
# XXX: Can this be made relative?
(cd %{buildroot}%{_datadir}/%{name}/doc && %__ln_s %{_javadocdir}/%{name} api)

%{__install} -m 0644 package-files/linux/%{name}.1 %{buildroot}/%{_mandir}/man1/

# script
%__cat > %{buildroot}%{_bindir}/%{name} << EOF
# jedit script
# JPackage Project <>
# Source functions library
. %{_datadir}/java-utils/java-functions
# Source system prefs
if [ -f %{_sysconfdir}/%{name}.conf ] ; then
  . %{_sysconfdir}/%{name}.conf
# Source user prefs
if [ -f \$HOME/.%{name}rc ] ; then
  . \$HOME/.%{name}rc
# Configuration
BASE_FLAGS="-Dbsh.jedit=true -Djedit.home=%{_datadir}/%{name} -mx32m"
BASE_JARS="aelfred asm bsh2/bsh-classgen bsh2/bsh-commands bsh2/bsh-core bsh2/bsh-reflect bsh2/bsh-util gnu.regexp %{name}"
#BASE_JARS="aelfred gnu.regexp %{name}"
# Set parameters
set_classpath \$BASE_JARS
set_flags \$BASE_FLAGS
# Let's start
run "\$@"
# icons
%__install -D -m 644 %{SOURCE3} %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
%__install -D -m 644 %{SOURCE2} %{buildroot}%{_datadir}/icons/hicolor/32x32/apps/%{name}.png
%__install -D -m 644 %{SOURCE1} %{buildroot}%{_datadir}/icons/hicolor/16x16/apps/%{name}.png

%fdupes -s %{buildroot}

%{__rm} -rf %{buildroot}

%attr(0755,root,root) %{_bindir}/%{name}
%exclude %{_datadir}/%{name}/doc/api
#%files manual
#%doc doc/users-guide/*

%files javadoc
%doc %{_javadocdir}/%{name}