Subject: [PATCH 22/31] gnu: Add java-dom4j.

From: Julien Lepiller <[email-masked]>
Date: Sun, 19 Nov 2017 18:57:56 +0100

* gnu/packages/java.scm (java-dom4j): New variable.
---
 gnu/packages/java.scm | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 2c535ceef..14a308348 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -8244,3 +8244,74 @@ efficiently all input elements (for example in SOAP processors).")
 parser and should be used when there is a need to process quickly and
 efficiently all input elements (for example in SOAP processors).")
     (license license:public-domain)))
+
+(define-public java-dom4j
+  (package
+    (name "java-dom4j")
+    (version "2.1.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/dom4j/dom4j/archive/"
+                                  "version-" version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "101drpnw6agmcvsi1jrfi0kn97r7liazrh5jbrip9vx26axn2fx9"))
+              (modules '((guix build utils)))
+              (snippet
+                '(begin ;; Delete bundled jar archives.
+                   (for-each delete-file (find-files "." ".*\\.jar"))
+                   #t))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "dom4j.jar"
+       #:jdk ,icedtea-8
+       #:source-dir "src/main/java"
+       #:tests? #f; Requires xalan, but xalan -> java-cup -> jflex -> java-cup...
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'copy-jaxen-sources
+           ;; jaxen-no-rec-deps is not enough. These files have a circular
+           ;; dependency and there is no subset of dom4j that would allow
+           ;; breaking the circle.
+           (lambda* (#:key inputs #:allow-other-keys)
+             (mkdir-p "jaxen-sources")
+             (with-directory-excursion "jaxen-sources"
+               (system* "jar" "xf" (assoc-ref inputs "java-jaxen-sources")))
+             (mkdir-p "src/main/java/org/jaxen/dom4j")
+             (copy-file "jaxen-sources/org/jaxen/dom4j/DocumentNavigator.java"
+                        "src/main/java/org/jaxen/dom4j/DocumentNavigator.java")
+             (copy-file "jaxen-sources/org/jaxen/dom4j/Dom4jXPath.java"
+                        "src/main/java/org/jaxen/dom4j/Dom4jXPath.java")
+             #t))
+         (add-before 'build 'fix-old-xpp2
+           (lambda _
+             ;; This package normally depends on xpp2 2.0, but we can only package
+             ;; version 2.1.10.
+             (substitute* "src/main/java/org/dom4j/xpp/ProxyXmlStartTag.java"
+               (("public void resetStartTag")
+                (string-append
+                  "public boolean removeAttributeByRawName(String name) {\n"
+                  "  return false;\n"
+                  "}\n"
+                  "public boolean removeAttributeByName(String name, String name2) {\n"
+                  "  return false;\n"
+                  "}\n"
+                  "\n"
+                  "public void resetStartTag"))
+               (("Atttribute") "Attribute"))
+             #t)))))
+    (inputs
+     `(("java-jaxen-no-rec-deps" ,java-jaxen-no-rec-deps)
+       ("java-jaxen-sources" ,(package-source java-jaxen-no-rec-deps))
+       ("java-xmlpull2" ,java-xmlpull2)
+       ("java-xpp3" ,java-xpp3)
+       ("java-xsdlib" ,java-xsdlib)))
+    (native-inputs
+     `(("java-testng" ,java-testng)
+       ("java-xerces" ,java-xerces)))
+    (home-page "https://dom4j.github.io/")
+    (synopsis "Flexible XML framework for Java")
+    (description "Dom4j is a flexible XML framework for Java.")
+    ;; some BSD-like 5-clause license
+    (license (license:non-copyleft "file://LICENSE"))))
-- 
2.15.0