Subject: [bug#31570] [PATCH 2/3] gnu: javacc: Use snippet to delete bundled jars.

From: Alex Vong <[email-masked]>
Date: Fri, 25 May 2018 08:22:29 +0800

From 16079becafbd7d9272f68a9d91412846697e3626 Mon Sep 17 00:00:00 2001
From: Alex Vong <[email-masked]>
Date: Fri, 25 May 2018 07:43:42 +0800
Subject: [PATCH 2/3] gnu: javacc: Use snippet to delete bundled jars.

* gnu/packages/java.scm (javacc-4)[source](snippet, modules): New fields.
[arguments]: Remove 'delete-bundled-libs' phase and add 'delete-tests'
phase.
* gnu/packages/java.scm (javacc)[source](snippet, modules): New fields.
[arguments]: Remove 'delete-bundled-libs' phase.
---
 gnu/packages/java.scm | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index c64313046..ce4a6b8ac 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -1873,7 +1873,10 @@ designs.")
               (file-name (string-append "javacc-" version "-checkout"))
               (sha256
                (base32
-                "07ysav7j8r1c6h8qxrgqk6lwdp74ly0ad1935lragxml0qqc3ka0"))))
+                "07ysav7j8r1c6h8qxrgqk6lwdp74ly0ad1935lragxml0qqc3ka0"))
+              (modules '((guix build utils)))
+              ;; delete bundled jars
+              (snippet '(begin (delete-file-recursively "lib") #t))))
     (build-system ant-build-system)
     ;; Tests fail with
     ;; /tmp/guix-build-javacc-4.1.drv-0/source/test/javacodeLA/build.xml:60:
@@ -1882,9 +1885,18 @@ designs.")
      `(#:tests? #f
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'delete-bundled-libs
+         ;; Delete tests to avoid build failure (we don't run them anyway).
+         (add-after 'unpack 'delete-tests
            (lambda _
-             (delete-file-recursively "lib") #t))
+             (for-each delete-file
+                       '("src/org/javacc/JavaCCTestCase.java"
+                         "src/org/javacc/parser/ExpansionTest.java"
+                         "src/org/javacc/parser/OptionsTest.java"
+                         "src/org/javacc/jjtree/JJTreeOptionsTest.java"))
+             (for-each delete-file-recursively
+                       '("src/org/javacc/parser/test"
+                         "src/org/javacc/jjdoc/test"))
+             #t))
          (replace 'install (install-jars "bin/lib")))))
     (home-page "https://javacc.org/")
     (synopsis "Java parser generator")
@@ -1908,14 +1920,14 @@ debugging, etc.")
               (file-name (string-append "javacc-" version ".tar.gz"))
               (sha256
                (base32
-                "111xc9mnmc5a6qz6x3xbhqc07y1lg2b996ggzw0hrblg42zya9xf"))))
+                "111xc9mnmc5a6qz6x3xbhqc07y1lg2b996ggzw0hrblg42zya9xf"))
+              (modules '((guix build utils)))
+              ;; delete bundled jars
+              (snippet '(begin (delete-file-recursively "lib") #t))))
     (arguments
      `(#:test-target "test"
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'delete-bundled-libs
-           (lambda _
-             (delete-file-recursively "lib") #t))
          (replace 'install (install-jars "target")))))))
 
 ;; This is the last 3.x release of ECJ
-- 
2.17.0