Subject: [bug#43639] [PATCH 16/16] gnu: groovy: Update to 3.0.5.

From: Julien Lepiller <[email-masked]>
Date: Sun, 27 Sep 2020 00:23:25 +0200

* gnu/packages/groovy.scm (groovy): Update to 3.0.5.
---
 gnu/packages/groovy.scm | 1430 ++++++++++++++++-----------------------
 1 file changed, 577 insertions(+), 853 deletions(-)

diff --git a/gnu/packages/groovy.scm b/gnu/packages/groovy.scm
index e21c4e3775..c44a17b59e 100644
--- a/gnu/packages/groovy.scm
+++ b/gnu/packages/groovy.scm
@@ -31,7 +31,7 @@
 (define java-groovy-bootstrap
   (package
     (name "java-groovy-bootstrap")
-    (version "2.4.15")
+    (version "3.0.5")
     (source
      (origin
        (method git-fetch)
@@ -43,57 +43,69 @@
                                   version)))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1q4cplimr18j93zz92kgq8b6wdv0p9svr7cdr47q8b2mbjpd0x3j"))
+        (base32 "00556qxjmcn3a3xhfy6n0zw3d69mnw72vzm2rb6n4ihzkk7579nm"))
        (patches
         (search-patches "groovy-add-exceptionutilsgenerator.patch"))))
     (build-system ant-build-system)
     (arguments
      `(#:jar-name "groovy.jar"
-       #:source-dir "src/main:subprojects/groovy-test/src/main/java"
+       #:source-dir "src/main/java:src/main/antlr2:subprojects/parser-antlr4/src/main/java:src/antlr"
        #:test-dir "src/test"
        #:tests? #f
-       #:jdk ,icedtea-8
+       #:jdk ,openjdk9
        #:main-class "groovy.ui.GroovyMain"
        #:phases
        (modify-phases %standard-phases
-         (add-before 'build 'fix-java8
-           ;; Fix "Reference to plus is ambiguous"
-           (lambda _
-             (substitute* "src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java"
-               (("toList\\(left\\)")
-                "(List<T>)toList(left)"))
-             #t))
          (add-before 'build 'generate-parsers
            (lambda _
-             (with-directory-excursion "src/main/org/codehaus/groovy/antlr/java"
+             (with-directory-excursion "src/main/antlr2/org/codehaus/groovy/antlr/java"
                (invoke "antlr" "java.g"))
-             (with-directory-excursion "src/main/org/codehaus/groovy/antlr"
+             (with-directory-excursion "src/main/antlr2/org/codehaus/groovy/antlr"
                (mkdir "parser")
                (with-directory-excursion "parser"
                  (invoke "antlr" "../groovy.g")))
+             (invoke "antlr4" "-lib" "src/antlr"
+                     "-package" "org.apache.groovy.parser.antlr4"
+                     "-visitor" "-no-listener" "src/antlr/GroovyLexer.g4")
+             (invoke "antlr4" "-lib" "src/antlr"
+                     "-package" "org.apache.groovy.parser.antlr4"
+                     "-visitor" "-no-listener" "src/antlr/GroovyParser.g4")
              #t))
          (add-before 'build 'generate-exception-utils
            (lambda _
              (invoke "javac" "-cp" (getenv "CLASSPATH")
+                     "-source" "1.8" "-target" "1.8"
                      "config/ant/src/org/codehaus/groovy/ExceptionUtilsGenerator.java")
              (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
                                                  ":config/ant/src")
                      "org.codehaus.groovy.ExceptionUtilsGenerator"
                      "build/classes/org/codehaus/groovy/runtime/ExceptionUtils.class")
+             #t))
+         (add-before 'build 'set-source-level
+           (lambda _
+             (substitute* "build.xml"
+               (("<javac") "<javac source=\"1.8\" target=\"1.8\""))
              #t)))))
     (native-inputs
-     `(("java-junit" ,java-junit)
+     `(("antlr2" ,antlr2)
+       ("antlr4" ,java-tunnelvisionlabs-antlr4)
+       ("java-jsr305" ,java-jsr305)
+       ("java-junit" ,java-junit)
        ("java-hamcrest-core" ,java-hamcrest-core)
-       ("antlr2" ,antlr2)
        ("java-jmock-1" ,java-jmock-1)
        ("java-xmlunit-legacy" ,java-xmlunit-legacy)))
     (inputs
-     `(("java-commons-cli" ,java-commons-cli)
-       ("java-asm" ,java-asm)
+     `(("java-antlr4-runtime" ,java-tunnelvisionlabs-antlr4-runtime)
+       ("java-antlr4-runtime-annotations"
+        ,java-tunnelvisionlabs-antlr4-runtime-annotations)
+       ("java-asm" ,java-asm-8)
+       ("java-asm-util" ,java-asm-util-8)
        ("java-classpathx-servletapi" ,java-classpathx-servletapi)
-       ("java-xstream" ,java-xstream)
+       ("java-commons-cli" ,java-commons-cli)
        ("java-jansi" ,java-jansi)
-       ("java-jline-2" ,java-jline-2)))
+       ("java-jline-2" ,java-jline-2)
+       ("java-picocli" ,java-picocli)
+       ("java-xstream" ,java-xstream)))
     (home-page "http://groovy-lang.org/")
     (synopsis "Groovy's java bootstrap")
     (description "This package contains the java bootstrap that is used to build
@@ -106,26 +118,25 @@ groovy submodules.")
     (name "groovy-bootstrap")
     (arguments
      `(#:jar-name "groovy.jar"
-       #:jdk ,icedtea-8
+       #:jdk ,openjdk9
        ;Requires groovy-xml and logback-classic which are circular dependencies
        #:tests? #f
        #:phases
        (modify-phases %standard-phases
-         (add-before 'build 'fix-java8
-           ;; Fix "Reference to plus is ambiguous"
-           (lambda _
-             (substitute* "src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java"
-               (("toList\\(left\\)")
-                "(List<T>)toList(left)"))
-             #t))
          (add-before 'build 'generate-parser
            (lambda _
-             (with-directory-excursion "src/main/org/codehaus/groovy/antlr/java"
+             (with-directory-excursion "src/main/antlr2/org/codehaus/groovy/antlr/java"
                (invoke "antlr" "java.g"))
-             (with-directory-excursion "src/main/org/codehaus/groovy/antlr"
+             (with-directory-excursion "src/main/antlr2/org/codehaus/groovy/antlr"
                (mkdir "parser")
                (with-directory-excursion "parser"
                  (invoke "antlr" "../groovy.g")))
+             (invoke "antlr4" "-lib" "src/antlr"
+                     "-package" "org.apache.groovy.parser.antlr4"
+                     "-visitor" "-no-listener" "src/antlr/GroovyLexer.g4")
+             (invoke "antlr4" "-lib" "src/antlr"
+                     "-package" "org.apache.groovy.parser.antlr4"
+                     "-visitor" "-no-listener" "src/antlr/GroovyParser.g4")
              #t))
          (add-before 'build 'generate-exception-utils
            (lambda _
@@ -141,19 +152,19 @@ groovy submodules.")
              (mkdir-p "target/classes/org/codehaus/groovy/runtime")
              (mkdir-p "target/classes/META-INF")
              (invoke "javac" "-cp" (getenv "CLASSPATH")
-                     "src/main/org/codehaus/groovy/tools/DgmConverter.java")
+                     "src/main/java/org/codehaus/groovy/tools/DgmConverter.java")
              (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
-                                                 ":src/main")
+                                                 ":src/main/java")
                      "org.codehaus.groovy.tools.DgmConverter")
              #t))
          (add-before 'build 'copy-resources
            (lambda _
-             (with-directory-excursion "src/main"
+             (with-directory-excursion "src/main/java"
                (for-each (lambda (file)
-                           (mkdir-p (string-append "../../target/classes/"
+                           (mkdir-p (string-append "../../../target/classes/"
                                                    (dirname file)))
                            (copy-file file
-                                      (string-append "../../target/classes/"
+                                      (string-append "../../../target/classes/"
                                                      file)))
                   (find-files "." ".*.(txt|properties|xml|html)")))
              #t))
@@ -162,6 +173,7 @@ groovy submodules.")
              (mkdir-p "build/jar")
              (apply invoke "java" "-cp" (getenv "CLASSPATH")
                            "org.codehaus.groovy.tools.FileSystemCompiler"
+                           "-cp" (getenv "CLASSPATH")
                            "-d" "target/classes"
                            "-j"; joint compilation
                            (find-files "src/main"
@@ -186,7 +198,7 @@ is used to build the groovy submodules written in groovy.")))
     (name "groovy-tests-bootstrap")
     (arguments
      `(#:jar-name "groovy-tests-bootstrap.jar"
-       #:jdk ,icedtea-8
+       #:jdk ,openjdk9
        #:tests? #f; no tests
        #:phases
        (modify-phases %standard-phases
@@ -196,17 +208,20 @@ is used to build the groovy submodules written in groovy.")))
              (mkdir-p "build/jar")
              (apply invoke "java" "-cp" (getenv "CLASSPATH")
                     "org.codehaus.groovy.tools.FileSystemCompiler"
+                    "-cp" (getenv "CLASSPATH")
                     "-d" "build/classes"
                     "-j"; joint compilation
                     (append
                       (find-files "src/test" "TestSupport.java")
                       (find-files "src/test" "HeadlessTestSupport.java")
+                      (find-files "src/test" "AstAssert.groovy")
                       (find-files "src/test" "XmlAssert.java")))
              (invoke "jar" "-cf" "build/jar/groovy-tests-bootstrap.jar"
                      "-C" "build/classes" ".")
              #t)))))
     (inputs
      `(("groovy-test" ,groovy-test)
+       ("groovy-parser-antlr4" ,groovy-parser-antlr4)
        ,@(package-inputs groovy-bootstrap)))
     (native-inputs
      `(("groovy-bootstrap" ,groovy-bootstrap)
@@ -215,855 +230,548 @@ is used to build the groovy submodules written in groovy.")))
     (description "This package contains three classes required for testing
 other groovy submodules.")))
 
+(define (groovy-subproject name)
+  (package
+    (inherit groovy-bootstrap)
+    (name name)
+    (arguments
+     `(#:jar-name ,(string-append name ".jar")
+       #:test-dir ,(string-append name "/src/test")
+       #:test-include (list "**/*Test.java" "**/*.groovy")
+       #:jdk ,openjdk9
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'build
+           (lambda _
+             (mkdir-p "build/classes")
+             (mkdir-p "build/jar")
+             (apply invoke "java" "-cp" (getenv "CLASSPATH")
+                    "org.codehaus.groovy.tools.FileSystemCompiler"
+                    "-cp" (getenv "CLASSPATH")
+                    "-d" "build/classes" "-j"
+                    (append
+                      (find-files ,(string-append "subprojects/" name "/src/main/java")
+                        ".*\\.(groovy|java)$")
+                      (find-files ,(string-append "subprojects/" name "/src/main/groovy")
+                        ".*\\.(groovy|java)$")))
+             (invoke "jar" "-cf" ,(string-append "build/jar/" name ".jar")
+                     "-C" "build/classes" ".")
+             #t))
+         (add-before 'build 'copy-resources
+           (lambda _
+             (let ((resource-dir ,(string-append "subprojects/" name
+                                                 "/src/main/resources")))
+               (when (file-exists? resource-dir)
+                 (copy-recursively resource-dir "build/classes")))
+             #t))
+         (replace 'check
+           (lambda* (#:key tests? #:allow-other-keys)
+             (when tests?
+               (mkdir-p "build/test-classes")
+               (substitute* "build.xml"
+                 (("depends=\"compile-tests\"") "depends=\"\"")
+                 (("}/java") "}/"))
+               (apply invoke "java" "-cp"
+                      (string-append (getenv "CLASSPATH") ":build/classes")
+                      "org.codehaus.groovy.tools.FileSystemCompiler" "-cp"
+                      (string-append (getenv "CLASSPATH") ":build/classes")
+                      "-d" "build/test-classes" "-j"
+                      (append
+                        (find-files ,(string-append "subprojects/" name "/src/test/java")
+                                    ".*\\.(groovy|java)$")
+                        (find-files ,(string-append "subprojects/" name "/src/test/groovy")
+                                    ".*\\.(groovy|java)$")))
+               (invoke "ant" "check"))
+             #t)))))))
+
+(define groovy-parser-antlr4
+  (let ((base (groovy-subproject "parser-antlr4")))
+    (package
+      (inherit base)
+      (name "groovy-parser-antlr4")
+      (arguments
+       `(#:tests? #f
+         ,@(substitute-keyword-arguments (package-arguments base)
+            ((#:phases phases)
+             `(modify-phases ,phases
+                (add-before 'build 'generate-parser
+                  (lambda _
+                    (invoke "antlr4" "-lib" "src/antlr"
+                            "-package" "org.apache.groovy.parser.antlr4"
+                            "-visitor" "-no-listener" "src/antlr/GroovyLexer.g4")
+                    (invoke "antlr4" "-lib" "src/antlr"
+                            "-package" "org.apache.groovy.parser.antlr4"
+                            "-visitor" "-no-listener" "src/antlr/GroovyParser.g4")
+                    (for-each
+                      (lambda (file)
+                        (install-file file
+                                      "subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4"))
+                      (find-files "src/antlr" ".*.java$"))
+                    #t)))))))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ,@(package-native-inputs java-groovy-bootstrap)))
+      (synopsis "Groovy antlr4 parser submodule")
+      (description "This package contains the new parser Parrot for Groovy, which
+is based on Antlr4.  The new parser can parse Groovy source code and construct
+the related AST, which is almost identical to the one generated by the old
+parser.  Currently all features of Groovy are available."))))
+
 (define groovy-test
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-test")
-    (arguments
-     `(#:jar-name "groovy-test.jar"
-       #:jdk ,icedtea-8
-       #:test-dir "subprojects/groovy-test/src/test"
-       #:phases
-       (modify-phases %standard-phases
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "subprojects/groovy-test/src/main"
-                                ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-test.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (append (find-files "subprojects/groovy-test/src/test"
-                                        ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy test submodule")
-    (description "This package contains the test submodules used to test
-other groovy submodules.")))
+  (let ((base (groovy-subproject "groovy-test")))
+    (package
+      (inherit base)
+      (arguments
+        `(;#:tests? #f
+          ,@(package-arguments base)))
+      (synopsis "Groovy test submodule")
+      (description "This package contains the test submodules used to test
+other groovy submodules."))))
 
 (define groovy-xml
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-xml")
-    (arguments
-     `(#:jar-name "groovy-xml.jar"
-       #:jdk ,icedtea-8
-       #:test-dir "src/test"
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-xml")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-xml.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (append (find-files "src/test" ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy XML")
-    (description "This package contains XML-related utilities for groovy.")))
+  (let ((base (groovy-subproject "groovy-xml")))
+    (package
+      (inherit base)
+      (native-inputs
+       `(("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (inputs
+       `(("groovy-parser-antlr4" ,groovy-parser-antlr4)
+         ,@(package-inputs base)))
+      (synopsis "Groovy XML")
+      (description "This package contains XML-related utilities for groovy."))))
 
 (define groovy-templates
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-templates")
-    (arguments
-     `(#:jar-name "groovy-templates.jar"
-       #:jdk ,icedtea-8
-       #:test-dir "subprojects/groovy-templates/src/test"
-       #:tests? #f;Requires spock-framework which is a circular dependency
-       #:phases
-       (modify-phases %standard-phases
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "subprojects/groovy-templates/src/main"
-                                ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-templates.jar"
-                     "-C" "build/classes" ".")
-             #t)))))
-    (inputs
-     `(("groovy-xml" ,groovy-xml)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy template engine")
-    (description "This package contains a template framework which is
+  (let ((base (groovy-subproject "groovy-templates")))
+    (package
+      (inherit base)
+      (arguments
+       `(#:tests? #f;Requires spock-framework which is a circular dependency
+         ,@(substitute-keyword-arguments (package-arguments base)
+             ((#:phases phases)
+              `(modify-phases ,phases
+                 ;; These annotations are used for QA, but do not affect build output.
+                 ;; They require findbugs, which we don't have yet.
+                 (add-before 'build 'remove-annotation
+                   (lambda _
+                     (substitute* '("subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java"
+                                    "subprojects/groovy-templates/src/main/groovy/groovy/text/TemplateEngine.java")
+                       (("import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;") "")
+                       (("@SuppressFBWarnings.*") ""))
+                     #t)))))))
+      (inputs
+       `(("groovy-xml" ,groovy-xml)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy template engine")
+      (description "This package contains a template framework which is
 well-suited to applications where the text to be generated follows the form of
-a static template.")))
+a static template."))))
 
 (define groovy-groovydoc
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-groovydoc")
-    (arguments
-     `(#:jar-name "groovy-groovydoc.jar"
-       #:jdk ,icedtea-8
-       #:test-dir "subprojects/groovy-groovydoc/src/test"
-       #:tests? #f; Requires groovy-ant which is a circular dependency
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'build 'copy-resources
-           (lambda _
-             (copy-recursively "subprojects/groovy-groovydoc/src/main/resources"
-                               "build/classes")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes"
-                    "-j"; joint compilation
-                    (find-files "subprojects/groovy-groovydoc/src/main"
-                                ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-groovydoc.jar"
-                     "-C" "build/classes" ".")
-             #t)))))
-    (inputs
-     `(("groovy-templates" ,groovy-templates)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy documentation generation")
-    (description "This package contains the groovy documentation generator,
-similar to javadoc.")))
+  (let ((base (groovy-subproject "groovy-groovydoc")))
+    (package
+      (inherit base)
+      (arguments
+       `(#:tests? #f; Requires groovy-ant which is a circular dependency
+         ,@(package-arguments base)))
+      (inputs
+       `(("groovy-templates" ,groovy-templates)
+         ("groovy-parser-antlr4" ,groovy-parser-antlr4)
+         ("java-javaparser" ,java-javaparser)
+         ,@(package-inputs groovy-bootstrap)))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs java-groovy-bootstrap)))
+      (synopsis "Groovy documentation generation")
+      (description "This package contains the groovy documentation generator,
+similar to javadoc."))))
 
 (define groovy-ant
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-ant")
-    (arguments
-     `(#:jar-name "groovy-ant.jar"
-       #:jdk ,icedtea-8
-       #:test-dir "src/test"
-       ;; FIXME: Excluding all tests because they fail
-       #:test-exclude (list
-                        "**/GroovyTest.java"
-                        "**/GroovycTest.java")
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-ant")
-             #t))
-         (add-before 'build 'copy-resources
-           (lambda _
-             (copy-recursively "src/main/resources" "build/classes")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-ant.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (find-files "src/test" ".*\\.(groovy|java)$"))
-             (invoke "ant" "check")
-             #t)))))
-    (inputs
-     `(("groovy-groovydoc" ,groovy-groovydoc)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-xml" ,groovy-xml)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy ant tasks")
-    (description "This package contains groovy-related ant tasks definitions.")))
+  (let ((base (groovy-subproject "groovy-ant")))
+    (package
+      (inherit base)
+      (arguments
+       `(;#:tests? #f;Requires spock-framework which is a circular dependency
+         #:ant ,ant/java8; ant is actually a dependency of this package, and we need 1.10
+         ,@(substitute-keyword-arguments (package-arguments base)
+             ((#:phases phases)
+              `(modify-phases ,phases
+                 ;; These annotations are used for QA, but do not affect build output.
+                 ;; They require findbugs, which we don't have yet.
+                 (add-before 'build 'remove-annotation
+                   (lambda _
+                     (substitute* (find-files "subprojects/groovy-ant"
+                                              ".*.java$")
+                       (("import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;") "")
+                       (("@SuppressFBWarnings.*") ""))
+                     #t)))))))
+      (inputs
+       `(("groovy-groovydoc" ,groovy-groovydoc)
+         ("java-asm-tree" ,java-asm-tree-8)
+         ("java-asm-analysis" ,java-asm-analysis-8)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("ant-junit" ,ant-junit)
+         ("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-xml" ,groovy-xml)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy ant tasks")
+      (description "This package contains groovy-related ant tasks definitions."))))
+
+(define groovy-astbuilder
+  (let ((base (groovy-subproject "groovy-astbuilder")))
+    (package
+      (inherit base)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (delete 'copy-resources)
+             (add-after 'build 'copy-resources
+               (lambda _
+                 (copy-recursively
+                   "subprojects/groovy-astbuilder/src/main/resources"
+                   "build/classes")
+                 (substitute* "build.xml"
+                   (("depends=\"compile,") "depends=\""))
+                 (invoke "ant" "jar")
+                 #t))))))
+      (inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Transformation to capture ASTBuilder from code statements")
+      (description "This package contains an AST transformation for use with
+ASTBuilder when building \"from string\" Groovy statements."))))
 
 (define groovy-bsf
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-bsf")
-    (arguments
-     `(#:jar-name "groovy-bsf.jar"
-       #:jdk ,icedtea-8
-       #:test-dir "src/test"
-       #:test-exclude (list
+  (let ((base (groovy-subproject "groovy-bsf")))
+    (package
+      (inherit base)
+      (arguments
+       `(#:test-exclude (list
 ;; exception from Groovy: org.codehaus.groovy.runtime.InvokerInvocationException:
 ;; groovy.lang.MissingMethodException: No signature of method:
 ;; java.util.ArrayList.each() is applicable for argument types:
 ;; (groovy.script.MapFromList$_doit_closure1) values:
 ;; [groovy.script.MapFromList$_doit_closure1@17e554d5]
                         "**/BSFTest.java")
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-bsf")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-bsf.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\""))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (find-files "src/test" ".*\\.(groovy|java)$"))
-             (invoke "ant" "check")
-             #t)))))
-    (inputs
-     `(("java-commons-bsf" ,java-commons-bsf)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ("java-commons-logging-minimal" ,java-commons-logging-minimal)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy BSF engine")
-    (description "This package defines the BSF engine for using Groovy inside
-any @dfn{Bean Scripting Framework} (BSF) application.")))
+         ,@(package-arguments base)))
+      (inputs
+       `(("java-commons-bsf" ,java-commons-bsf)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ("java-commons-logging-minimal" ,java-commons-logging-minimal)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy BSF engine")
+      (description "This package defines the BSF engine for using Groovy inside
+any @dfn{Bean Scripting Framework} (BSF) application."))))
+
+(define groovy-cli-commons
+  (let ((base (groovy-subproject "groovy-cli-commons")))
+    (package
+      (inherit base)
+      (inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-test" ,groovy-test)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy CLI common classes")
+      (description "This package defines common classes for dealing with
+command-line arguments in Groovy."))))
+
+(define groovy-cli-picocli
+  (let ((base (groovy-subproject "groovy-cli-picocli")))
+    (package
+      (inherit base)
+      (inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("java-picocli" ,java-picocli)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-test" ,groovy-test)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy CLI classes that use picocli")
+      (description "This package defines classes for dealing with command-line
+arguments in Groovy using the picocli library."))))
 
 (define groovy-swing
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-swing")
-    (arguments
-     `(#:jar-name "groovy-swing.jar"
-       #:jdk ,icedtea-8
-       ;; FIXME: tests are not run
-       #:test-dir "src/test"
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-swing")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-swing.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "src/test/groovy/groovy/util/GroovySwingTestCase.groovy"
-               (("HeadlessTestSupport.headless") "isHeadless()"))
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (find-files "src/test" ".*\\.(groovy|java)$"))
-             (invoke "ant" "check")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ("java-commons-logging-minimal" ,java-commons-logging-minimal)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy graphical library")
-    (description "This package contains the groovy bindings to Java Swing, a
-library used to build graphical interfaces.")))
+  (let ((base (groovy-subproject "groovy-swing")))
+    (package
+      (inherit base)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-before 'check 'fix-test
+               (lambda _
+                 (substitute*
+                   "subprojects/groovy-swing/src/test/groovy/groovy/swing/GroovySwingTestCase.groovy"
+                   (("HeadlessTestSupport.headless") "isHeadless()"))
+                 #t))))))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ("java-commons-logging-minimal" ,java-commons-logging-minimal)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy graphical library")
+      (description "This package contains the groovy bindings to Java Swing, a
+library used to build graphical interfaces."))))
 
 (define groovy-console
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-console")
-    (arguments
-     `(#:jar-name "groovy-console.jar"
-       #:jdk ,icedtea-8
-       ;; FIXME: tests are not run
-       #:test-dir "src/test"
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-console")
-             #t))
-         (add-before 'build 'copy-resources
-           (lambda _
-             (copy-recursively "src/main/resources" "build/classes")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-console.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (substitute*
-               "../groovy-swing/src/test/groovy/groovy/util/GroovySwingTestCase.groovy"
-               (("HeadlessTestSupport.headless") "isHeadless()"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (append
-                      (find-files "../groovy-swing/src/test" ".*\\.(groovy|java)$")
-                      (find-files "src/test" ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (inputs
-     `(("groovy-swing" ,groovy-swing)
-       ("groovy-templates" ,groovy-templates)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ("java-commons-logging-minimal" ,java-commons-logging-minimal)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy graphical interface")
-    (description "This package contains a graphical interface to run groovy.")))
+  (let ((base (groovy-subproject "groovy-console")))
+    (package
+      (inherit base)
+      (arguments
+         (substitute-keyword-arguments (package-arguments base)
+           ((#:phases phases)
+            `(modify-phases ,phases
+               (add-before 'check 'build-swing
+                 (lambda _
+                   (substitute*
+                     "subprojects/groovy-swing/src/test/groovy/groovy/swing/GroovySwingTestCase.groovy"
+                     (("HeadlessTestSupport.headless") "isHeadless()"))
+                   (mkdir-p "build/test-classes")
+                   (apply invoke "java" "-cp"
+                          (string-append (getenv "CLASSPATH") ":build/classes")
+                          "org.codehaus.groovy.tools.FileSystemCompiler" "-cp"
+                          (string-append (getenv "CLASSPATH") ":build/classes")
+                          "-d" "build/test-classes" "-j"
+                          (append
+                            (find-files "subprojects/groovy-swing/src/test/java"
+                                        ".*\\.(groovy|java)$")
+                            (find-files "subprojects/groovy-swing/src/test/groovy"
+                                        ".*\\.(groovy|java)$")))
+                   #t))))))
+      (inputs
+       `(("groovy-swing" ,groovy-swing)
+         ("groovy-templates" ,groovy-templates)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ("java-commons-logging-minimal" ,java-commons-logging-minimal)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy graphical interface")
+      (description "This package contains a graphical interface to run groovy."))))
+
+(define groovy-datetime
+  (let ((base (groovy-subproject "groovy-datetime")))
+    (package
+      (inherit base)
+      (native-inputs
+       `(("groovy-test" ,groovy-test)
+         ,@(package-native-inputs base)))
+      (synopsis "Date/Time API for Groovy")
+      (description "This package defines new Groovy methods which appear on
+normal JDK Date/Time API (@code{java.time}) classes inside the Groovy
+environment."))))
+
+(define groovy-dateutil
+  (let ((base (groovy-subproject "groovy-dateutil")))
+    (package
+      (inherit base)
+      (native-inputs
+       `(("groovy-test" ,groovy-test)
+         ,@(package-native-inputs base)))
+      (synopsis "Date and Calendar API for Groovy")
+      (description "This package defines new groovy methods which appear on
+normal JDK Date and Calendar classes inside the Groovy environment."))))
 
 (define groovy-docgenerator
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-docgenerator")
-    (arguments
-     `(#:jar-name "groovy-docgenerator.jar"
-       #:jdk ,icedtea-8
-       #:tests? #f; No tests
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-docgenerator")
-             #t))
-         (add-before 'build 'copy-resources
-           (lambda _
-             (copy-recursively "src/main/resources" "build/classes")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-docgenerator.jar"
-                     "-C" "build/classes" ".")
-             #t)))))
-    (inputs
-     `(("groovy-templates" ,groovy-templates)
-       ("groovy-swing" ,groovy-swing)
-       ("java-qdox-1.12" ,java-qdox-1.12)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy documentation generation")
-    (description "This package contains a command line tool to generate
-documentation for groovy applications.")))
+  (let ((base (groovy-subproject "groovy-docgenerator")))
+    (package
+      (inherit base)
+      (arguments
+       `(#:tests? #f; No tests
+         ,@(package-arguments base)))
+      (inputs
+       `(("groovy-templates" ,groovy-templates)
+         ("groovy-swing" ,groovy-swing)
+         ("java-qdox-1.12" ,java-qdox-1.12)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy documentation generation")
+      (description "This package contains a command line tool to generate
+documentation for groovy applications."))))
 
 (define groovy-groovysh
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-groovysh")
-    (arguments
-     `(#:jar-name "groovy-groovysh.jar"
-       #:test-dir "src/test"
-       #:jdk ,icedtea-8
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-groovysh")
-             #t))
-         (add-before 'build 'copy-resources
-           (lambda _
-             (copy-recursively "src/main/resources" "build/classes")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-groovysh.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (append (find-files "src/test" ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (inputs
-     `(("groovy-xml" ,groovy-xml)
-       ("groovy-console" ,groovy-console)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy REPL")
-    (description "This package contains the Groovy REPL.")))
+  (let ((base (groovy-subproject "groovy-groovysh")))
+    (package
+      (inherit base)
+      (inputs
+       `(("groovy-xml" ,groovy-xml)
+         ("groovy-console" ,groovy-console)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy REPL")
+      (description "This package contains the Groovy REPL."))))
 
 (define groovy-jmx
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-jmx")
-    (arguments
-     `(#:jar-name "groovy-jmx.jar"
-       #:test-dir "src/test"
-       #:jdk ,icedtea-8
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-jmx")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                      "org.codehaus.groovy.tools.FileSystemCompiler"
-                      "-d" "build/classes" "-j"; joint compilation
-                      (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-jmx.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (append (find-files "src/test" ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy JMX extension")
-    (description "This package contains the JMX extension of Groovy, for
-management and monitoring of JVM-based solutions.")))
+  (let ((base (groovy-subproject "groovy-jmx")))
+    (package
+      (inherit base)
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy JMX extension")
+      (description "This package contains the JMX extension of Groovy, for
+management and monitoring of JVM-based solutions."))))
 
 (define groovy-json
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-json")
-    (arguments
-     `(#:jar-name "groovy-json.jar"
-       #:test-dir "src/test"
-       #:jdk ,icedtea-8
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-json")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                      "org.codehaus.groovy.tools.FileSystemCompiler"
-                      "-d" "build/classes" "-j"; joint compilation
-                      (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-json.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (append (find-files "src/test" ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy JSON")
-    (description "This package contains JSON-related utilities for groovy.")))
+  (let ((base (groovy-subproject "groovy-json")))
+    (package
+      (inherit base)
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy JSON")
+      (description "This package contains JSON-related utilities for groovy."))))
 
 (define groovy-jsr223
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-jsr223")
-    (arguments
-     `(#:jar-name "groovy-jsr223.jar"
-       #:test-dir "src/test"
-       #:jdk ,icedtea-8
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-jsr223")
-             #t))
-         (add-before 'build 'copy-resources
-           (lambda _
-             (copy-recursively "src/main/resources" "build/classes")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                      "org.codehaus.groovy.tools.FileSystemCompiler"
-                      "-d" "build/classes" "-j"; joint compilation
-                      (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-jsr223.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes" "-j"
-                    (append (find-files "src/test" ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy's own JSR223 implementation")
-    (description "This package contains Groovy's own JSR223 implementation.  This
-module is used for interaction between Groovy and Java code.")))
+  (let ((base (groovy-subproject "groovy-jsr223")))
+    (package
+      (inherit base)
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy's own JSR223 implementation")
+      (description "This package contains Groovy's own JSR223 implementation.  This
+module is used for interaction between Groovy and Java code."))))
 
 (define groovy-nio
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-nio")
-    (arguments
-     `(#:jar-name "groovy-nio.jar"
-       #:test-dir "src/test"
-       #:jdk ,icedtea-8
-       #:tests? #f; Requires spock-framework
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-nio")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-nio.jar"
-                     "-C" "build/classes" ".")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy input-output library")
-    (description "This package implements an input/output library that extends
-the functionality of the common library of Java.")))
+  (let ((base (groovy-subproject "groovy-nio")))
+    (package
+      (inherit base)
+      (arguments
+       `(#:tests? #f; Require spock-framework
+         ,@(package-arguments base)))
+      (synopsis "Groovy input-output library")
+      (description "This package implements an input/output library that extends
+the functionality of the common library of Java."))))
 
 (define groovy-servlet
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-servlet")
-    (arguments
-     `(#:jar-name "groovy-servlet.jar"
-       #:test-dir "src/test"
-       #:jdk ,icedtea-8
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-servlet")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes"
-                    "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-servlet.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                    (string-append (getenv "CLASSPATH") ":build/classes")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/test-classes"
-                    "-j"
-                    (append (find-files "src/test" ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (inputs
-     `(("groovy-templates" ,groovy-templates)
-       ("groovy-xml" ,groovy-xml)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-json" ,groovy-json)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy's servlet implementation")
-    (description "This package contains a library to create groovlets, Groovy's
-version of Java servlets.")))
+  (let ((base (groovy-subproject "groovy-servlet")))
+    (package
+      (inherit base)
+      (inputs
+       `(("groovy-templates" ,groovy-templates)
+         ("groovy-xml" ,groovy-xml)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-json" ,groovy-json)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy's servlet implementation")
+      (description "This package contains a library to create groovlets, Groovy's
+version of Java servlets."))))
 
 (define groovy-sql
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-sql")
-    (arguments
-     `(#:jar-name "groovy-sql.jar"
-       #:test-dir "src/test"
-       #:tests? #f;TODO: Requires hsqldb
-       #:jdk ,icedtea-8
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-sql")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                      "org.codehaus.groovy.tools.FileSystemCompiler"
-                      "-d" "build/classes" "-j"; joint compilation
-                      (find-files "src/main"
-                                  ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-sql.jar"
-                     "-C" "build/classes" ".")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy SQL library")
-    (description "This package contains a facade over Java's normal JDBC APIs
-providing greatly simplified resource management and result set handling.")))
+  (let ((base (groovy-subproject "groovy-sql")))
+    (package
+      (inherit base)
+      (arguments
+       `(#:tests? #f;TODO: Requires hsqldb
+         ,@(package-arguments base)))
+      (synopsis "Groovy SQL library")
+      (description "This package contains a facade over Java's normal JDBC APIs
+providing greatly simplified resource management and result set handling."))))
 
 (define groovy-testng
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-testng")
-    (arguments
-     `(#:jar-name "groovy-testng.jar"
-       #:tests? #f; No tests
-       #:jdk ,icedtea-8
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-testng")
-             #t))
-         (add-before 'build 'copy-resources
-           (lambda _
-             (copy-recursively "src/main/resources" "build/classes")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes"
-                    "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-testng.jar"
-                     "-C" "build/classes" ".")
-             #t)))))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy testing framework")
-    (description "This package contains integration code for running TestNG
-tests in Groovy.")))
+  (let ((base (groovy-subproject "groovy-testng")))
+    (package
+      (inherit base)
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy testing framework")
+      (description "This package contains integration code for running TestNG
+tests in Groovy."))))
 
 (define groovy-macro
-  (package
-    (inherit groovy-bootstrap)
-    (name "groovy-macro")
-    (arguments
-     `(#:jar-name "groovy-macro.jar"
-       #:test-dir "src/test"
-       #:jdk ,icedtea-8
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "subprojects/groovy-macro")
-             #t))
-         (replace 'build
-           (lambda _
-             (mkdir-p "build/classes")
-             (mkdir-p "build/jar")
-             (apply invoke "java" "-cp" (getenv "CLASSPATH")
-                    "org.codehaus.groovy.tools.FileSystemCompiler"
-                    "-d" "build/classes" "-j"; joint compilation
-                    (find-files "src/main" ".*\\.(groovy|java)$"))
-             (invoke "jar" "-cf" "build/jar/groovy-macro.jar"
-                     "-C" "build/classes" ".")
-             #t))
-         (replace 'check
-           (lambda _
-             (mkdir-p "build/test-classes")
-             (substitute* "build.xml"
-               (("depends=\"compile-tests\"") "depends=\"\"")
-               (("}/java") "}/groovy"))
-             (apply invoke "java" "-cp"
-                   (string-append (getenv "CLASSPATH") ":build/classes")
-                   "org.codehaus.groovy.tools.FileSystemCompiler"
-                   "-d" "build/test-classes" "-j"
-                   (append (find-files "src/test" ".*\\.(groovy|java)$")))
-             (invoke "ant" "check")
-             #t)))))
-    (inputs
-     `(("groovy-templates" ,groovy-templates)
-       ("groovy-xml" ,groovy-xml)
-       ,@(package-inputs groovy-bootstrap)))
-    (native-inputs
-     `(("groovy-bootstrap" ,groovy-bootstrap)
-       ("groovy-json" ,groovy-json)
-       ("groovy-test" ,groovy-test)
-       ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
-       ,@(package-native-inputs java-groovy-bootstrap)))
-    (synopsis "Groovy macro processor")
-    (description "This package contains a high-level library to create macro
-and modify groovy's @dfn{Abstract Syntax Tree} (AST).")))
+  (let ((base (groovy-subproject "groovy-macro")))
+    (package
+      (inherit base)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (delete 'copy-resources)
+             (add-after 'build 'copy-resources
+               (lambda _
+                 (copy-recursively "subprojects/groovy-macro/src/main/resources"
+                                   "build/classes")
+                 (substitute* "build.xml"
+                   (("depends=\"compile,") "depends=\""))
+                 (invoke "ant" "jar")
+                 #t))))))
+      (inputs
+       `(("groovy-templates" ,groovy-templates)
+         ("groovy-xml" ,groovy-xml)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-bootstrap" ,groovy-bootstrap)
+         ("groovy-json" ,groovy-json)
+         ("groovy-test" ,groovy-test)
+         ("groovy-tests-bootstrap" ,groovy-tests-bootstrap)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy macro processor")
+      (description "This package contains a high-level library to create macro
+and modify groovy's @dfn{Abstract Syntax Tree} (AST)."))))
+
+(define groovy-yaml
+  (let ((base (groovy-subproject "groovy-yaml")))
+    (package
+      (inherit base)
+      (inputs
+       `(("groovy-json" ,groovy-json)
+         ("java-fasterxml-jackson-annotations" ,java-fasterxml-jackson-annotations)
+         ("java-fasterxml-jackson-core" ,java-fasterxml-jackson-core)
+         ("java-fasterxml-jackson-databind" ,java-fasterxml-jackson-databind)
+         ("java-fasterxml-jackson-dataformat-yaml" ,java-fasterxml-jackson-dataformat-yaml)
+         ,@(package-inputs base)))
+      (native-inputs
+       `(("groovy-test" ,groovy-test)
+         ,@(package-native-inputs base)))
+      (synopsis "Groovy YAML")
+      (description "This package contains YAML-related utilities for groovy."))))
 
 (define-public groovy
   (package
@@ -1071,7 +779,7 @@ and modify groovy's @dfn{Abstract Syntax Tree} (AST).")))
     (name "groovy")
     (arguments
      `(#:tests? #f; No tests
-       #:jdk ,icedtea-8
+       #:jdk ,openjdk9
        #:phases
        (modify-phases %standard-phases
          (delete 'configure)
@@ -1089,7 +797,7 @@ and modify groovy's @dfn{Abstract Syntax Tree} (AST).")))
                    (("@GROOVYJAR@") "groovy.jar")
                    (("MAX_FD=\"maximum\"")
                     (string-append
-                      "MAX_FD=\"maximum\"\nJAVAHOME="
+                      "MAX_FD=\"maximum\"\nJAVA_HOME="
                       (assoc-ref inputs "jdk"))))
                  ;; Groovy uses class loading. It's not enough to put the class
                  ;; in the loader's classpath, as it causes breakages:
@@ -1105,14 +813,17 @@ and modify groovy's @dfn{Abstract Syntax Tree} (AST).")))
                        (lambda (jar)
                          (symlink jar (string-append out-lib "/" (basename jar))))
                        (find-files (assoc-ref inputs input) ".*.jar")))
-                   '("groovy-bootstrap" "groovy-ant" "groovy-bsf"
-                     "groovy-console" "groovy-docgenerator"
-                     "groovy-groovydoc" "groovy-groovysh"
-                     "groovy-jmx" "groovy-json" "groovy-jsr223"
-                     "groovy-nio" "groovy-servlet" "groovy-sql"
+                   '("groovy-bootstrap" "groovy-ant" "groovy-astbuilder"
+                     "groovy-bsf" "groovy-cli-commons" "groovy-cli-picocli"
+                     "groovy-console" "groovy-datetime" "groovy-dateutil"
+                     "groovy-docgenerator" "groovy-groovydoc" "groovy-groovysh"
+                     "groovy-jmx" "groovy-json" "groovy-jsr223" "groovy-nio"
+                     "groovy-parser-antlr4" "groovy-servlet" "groovy-sql"
                      "groovy-swing" "groovy-templates" "groovy-testng"
-                     "groovy-xml" "java-commons-cli" "java-asm"
-                     "java-classpathx-servletapi" "java-xstream"
+                     "groovy-xml" "groovy-yaml" "java-commons-cli"
+                     "java-tunnelvisionlabs-antlr4-runtime" "java-asm"
+                     "java-asm-analysis" "java-asm-tree" "java-asm-util"
+                     "java-classpathx-servletapi" "java-xstream" "java-picocli"
                      "java-jansi" "java-jline-2"))
                  ;; antlr.jar is present twice in antlr2.  Symlink doesn't like
                  ;; it, so we symlink it here.
@@ -1130,8 +841,13 @@ and modify groovy's @dfn{Abstract Syntax Tree} (AST).")))
     (inputs
      `(("groovy-bootstrap" ,groovy-bootstrap)
        ("groovy-ant" ,groovy-ant)
+       ("groovy-astbuilder" ,groovy-astbuilder)
        ("groovy-bsf" ,groovy-bsf)
+       ("groovy-cli-commons" ,groovy-cli-commons)
+       ("groovy-cli-picocli" ,groovy-cli-picocli)
        ("groovy-console" ,groovy-console)
+       ("groovy-datetime" ,groovy-datetime)
+       ("groovy-dateutil" ,groovy-dateutil)
        ("groovy-docgenerator" ,groovy-docgenerator)
        ("groovy-groovydoc" ,groovy-groovydoc)
        ("groovy-groovysh" ,groovy-groovysh)
@@ -1139,18 +855,26 @@ and modify groovy's @dfn{Abstract Syntax Tree} (AST).")))
        ("groovy-json" ,groovy-json)
        ("groovy-jsr223" ,groovy-jsr223)
        ("groovy-nio" ,groovy-nio)
+       ("groovy-parser-antlr4" ,groovy-parser-antlr4)
        ("groovy-servlet" ,groovy-servlet)
        ("groovy-sql" ,groovy-sql)
        ("groovy-swing" ,groovy-swing)
        ("groovy-templates" ,groovy-templates)
        ("groovy-testng" ,groovy-testng)
        ("groovy-xml" ,groovy-xml)
+       ("groovy-yaml" ,groovy-yaml)
+       ("java-tunnelvisionlabs-antlr4-runtime"
+        ,java-tunnelvisionlabs-antlr4-runtime)
        ("java-commons-cli" ,java-commons-cli)
-       ("java-asm" ,java-asm)
+       ("java-asm" ,java-asm-8)
+       ("java-asm-analysis" ,java-asm-analysis-8)
+       ("java-asm-tree" ,java-asm-tree-8)
+       ("java-asm-util" ,java-asm-util-8)
        ("java-classpathx-servletapi" ,java-classpathx-servletapi)
-       ("java-xstream" ,java-xstream)
+       ("java-picocli" ,java-picocli)
        ("java-jansi" ,java-jansi)
        ("java-jline-2" ,java-jline-2)
+       ("java-xstream" ,java-xstream)
        ("antlr2" ,antlr2)))
     (synopsis "Programming language for the JVM")
     (description "Apache Groovy is a powerful, optionally typed and dynamic
-- 
2.28.0