[bug#32947] Add java-xalan.

Message ID 871qz0nv7s.fsf@Ginko.local.i-did-not-set--mail-host-address--so-tickle-me
State New
Headers
Series [bug#32947] Add java-xalan. |

Commit Message

Frank Pursel March 17, 2022, 9:08 p.m. UTC
  Hi Guix!

I want to help get a version of xalan into guix.  I independently posted
issue#54145 to this end but errors were made.  I've since learned of and
from this prior work and want to offer an updated/improved patch to provide a
java-xalan-interp package to fill this gap.

This package is less ambitious than the original because it makes no
attempt to build the xsltc base of xalan and instead settles for the
likely slower, xslt base.  The xslt base of xalan is likely slower than
the xsltc base but, as far as I can tell, it provides the same
functionality while not depending on the bundled cups and jflex jars.

If it meets your scrutiny we may also be able to close two issues (this,
32947 and 54145) for the price of one!  

Regards,
Frank Pursel
acrow#guix

From 6d711a86959049596e6c6110a830ba1c6c7cea50 Mon Sep 17 00:00:00 2001
Message-Id: <6d711a86959049596e6c6110a830ba1c6c7cea50.1647548555.git.frank.pursel@gmail.com>
From: Frank Pursel <frank.pursel@gmail.com>
Date: Wed, 23 Feb 2022 13:59:26 -0800
Subject: [PATCH] gnu: Add java-xalan-interp

     * gnu/packages/xml.scm (java-xalan-interp): New variable
---
 gnu/packages/xml.scm | 62 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
  

Comments

Maxime Devos March 17, 2022, 9:50 p.m. UTC | #1
Frank Pursel schreef op do 17-03-2022 om 14:08 [-0700]:
> +    (version "j_2_7_2")

Why not use periods instead of underscores and drop the "j_" prefix
("2.7.2") instead?  'version-major+minor' and 'version-compare' would
like that better I think, and it's more in line with other packages.

Greetings,
Maxime.
  
Maxime Devos March 17, 2022, 9:53 p.m. UTC | #2
Frank Pursel schreef op do 17-03-2022 om 14:08 [-0700]:
> +       (snippet '(begin
> +                   ;; Removing bundled jars
> +                   (format #t "~%~a~%" "Removing Bundled Jars")

Isn't this equivalent to (display "Removing bundled jars\n")?

> +                   (for-each
> +                    (lambda (f)
> +                      (format #t "~/Deleting: ~a~%" f)

Why ~/?

> +                      (delete-file f))
> +                    (find-files "." "\\.jar$"))))))

FWIW, while this is useful for testing whether the unbundling works (*)
while developing the patch, I personally don't see the point of keeping
the 'format' afterwards.

(*) alternatively, you can do "guix build --source java-xalan" to test.

Greetings,
Maxime.
  
Maxime Devos March 17, 2022, 9:57 p.m. UTC | #3
Frank Pursel schreef op do 17-03-2022 om 14:08 [-0700]:
> +                (add-after 'install 'provide-jars-for-indexing
> +                  (lambda* (#:key inputs outputs #:allow-other-keys)
> +                    (with-directory-excursion
> +                        (string-append (assoc-ref outputs "out") "/share/java")
> +                      (symlink
> +                       (search-input-file inputs "share/java/jaxp.jar")
> +                       "jaxp.jar")
> +                      (symlink
> +                       (search-input-file inputs "share/java/xercesImpl.jar")
> +                       "xercesImpl.jar")))))))

Why is "jaxp" and "xerces" being symlinked into share/java even though
they are propagated?  Could they be removed after indexing?  Is
generate-jar-indices currently broken?

Greetings
Maxime.
  
Maxime Devos March 18, 2022, 5:40 p.m. UTC | #4
Frank Pursel schreef op do 17-03-2022 om 14:08 [-0700]:
> +       (snippet '(begin
> +                   ;; Removing bundled jars
> +                   (format #t "~%~a~%" "Removing Bundled Jars")
> +                   (for-each
> +                    (lambda (f)
> +                      (format #t "~/Deleting: ~a~%" f)
> +                      (delete-file f))
> +                    (find-files "." "\\.jar$"))))))

I looked a little further and saw a few 'tar.gz'.  Perhaps those need
to be removed as well?
  
Frank Pursel March 18, 2022, 6:15 p.m. UTC | #5
Deleting the tar.gz's too should be fine.   And the change regarding the
Class-Path sounds appropriate too.  Thank you.


On Fri, Mar 18, 2022 at 5:41 PM Maxime Devos <maximedevos@telenet.be> wrote:

> Frank Pursel schreef op do 17-03-2022 om 14:08 [-0700]:
> > +       (snippet '(begin
> > +                   ;; Removing bundled jars
> > +                   (format #t "~%~a~%" "Removing Bundled Jars")
> > +                   (for-each
> > +                    (lambda (f)
> > +                      (format #t "~/Deleting: ~a~%" f)
> > +                      (delete-file f))
> > +                    (find-files "." "\\.jar$"))))))
>
> I looked a little further and saw a few 'tar.gz'.  Perhaps those need
> to be removed as well?
>
  
Frank Pursel March 18, 2022, 6:22 p.m. UTC | #6
I like the string-replace-substring modification in your revision but you
need to also allow for the '-j' prefix artifact that the apache upstream is
calling for.

On Fri, Mar 18, 2022 at 6:15 PM Frank Pursel <frank.pursel@gmail.com> wrote:

> Deleting the tar.gz's too should be fine.   And the change regarding the
> Class-Path sounds appropriate too.  Thank you.
>
>
> On Fri, Mar 18, 2022 at 5:41 PM Maxime Devos <maximedevos@telenet.be>
> wrote:
>
>> Frank Pursel schreef op do 17-03-2022 om 14:08 [-0700]:
>> > +       (snippet '(begin
>> > +                   ;; Removing bundled jars
>> > +                   (format #t "~%~a~%" "Removing Bundled Jars")
>> > +                   (for-each
>> > +                    (lambda (f)
>> > +                      (format #t "~/Deleting: ~a~%" f)
>> > +                      (delete-file f))
>> > +                    (find-files "." "\\.jar$"))))))
>>
>> I looked a little further and saw a few 'tar.gz'.  Perhaps those need
>> to be removed as well?
>>
>
  
Maxime Devos March 18, 2022, 7:19 p.m. UTC | #7
Frank Pursel schreef op vr 18-03-2022 om 18:22 [+0000]:
> I like the string-replace-substring modification in your revision but
> you need to also allow for the '-j' prefix artifact that the apache
> upstream is calling for.

Indeed:

(string-append "mirror://apache/xalan/xalan-j/source/xalan-j_"
               (string-replace-substring version "." "_")
               "-src.tar.gz")

Greetings,
Maxime.
  

Patch

diff --git a/gnu/packages/xml.scm b/gnu/packages/xml.scm
index 3ce5e771c7..94bcdff903 100644
--- a/gnu/packages/xml.scm
+++ b/gnu/packages/xml.scm
@@ -33,6 +33,7 @@ 
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2021 David Larsson <david.larsson@selfhosted.xyz>
 ;;; Copyright © 2021 Matthew James Kraai <kraai@ftbfs.org>
+;;; Copyright © 2022 Frank Pursel <frank.pursel@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2592,3 +2593,64 @@  (define-public python-xmltodict
     (description "This package provides a Python library to convert XML to
 @code{OrderedDict}.")
     (license license:expat)))
+
+(define-public java-xalan-interp
+  (package
+    (name "java-xalan-interp")
+    (version "j_2_7_2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://apache/xalan/xalan-j/source/xalan-"
+                           version "-src.tar.gz"))
+       (sha256
+        (base32 "166vg9i11qzi0vbv09abfb50q8caq8wr6zrwg0cwqws9k394l62w"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   ;; Removing bundled jars
+                   (format #t "~%~a~%" "Removing Bundled Jars")
+                   (for-each
+                    (lambda (f)
+                      (format #t "~/Deleting: ~a~%" f)
+                      (delete-file f))
+                    (find-files "." "\\.jar$"))))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:phases (modify-phases
+                %standard-phases
+                (add-after 'unpack 'prepare-for-build
+                  (lambda* (#:key inputs outputs #:allow-other-keys)
+                    (setenv "ANT_OPTS" "-Dxsltc.java_cup.not_needed=true")
+                    (substitute* "build.xml"
+                      ;; Only the interpretive compiler.  xsltc contains a
+                      ;; circular reference java_cup.
+                      (("(<target name=\"jar\" depends=\"xalan-interpretive.compile),.*"
+                        all pre)
+                       (string-append pre "\""))
+                      (("xml-apis") "jaxp"))
+                    (substitute* (list "src/MANIFEST.MF"
+                                       "src/manifest.xalan-interpretive"
+                                       "src/MANIFEST.SERIALIZER"
+                                       "src/manifest.xsltc")
+                      (("xml-apis.jar") "jaxp.jar"))))
+                (replace 'install
+                  (install-jars "build"))
+                (add-after 'install 'provide-jars-for-indexing
+                  (lambda* (#:key inputs outputs #:allow-other-keys)
+                    (with-directory-excursion
+                        (string-append (assoc-ref outputs "out") "/share/java")
+                      (symlink
+                       (search-input-file inputs "share/java/jaxp.jar")
+                       "jaxp.jar")
+                      (symlink
+                       (search-input-file inputs "share/java/xercesImpl.jar")
+                       "xercesImpl.jar")))))))
+    (native-inputs (list java-junit java-hamcrest-core))
+    (propagated-inputs (list java-jaxp java-xerces))
+    (home-page "https://xalan.apache.org/xalan-j/index.html")
+    (synopsis "Java XSLT processor")
+    (description "XSLT processor in java implementing XSLT Version 1.0, XPath
+Version 1.0, and JAXP 1.3.  It builds on SAX2 and DOM level 3.  This version
+is the fully functional interpreter, xslt, not the xsltc version which may be
+faster.")
+    (license license:asl2.0)))