Subject: [bug#31333] [PATCH 02/22] gnu: Add groovy-bootstrap.

From: Julien Lepiller <[email-masked]>
Date: Tue, 1 May 2018 17:44:29 +0200

* gnu/packages/groovy.scm (groovy-bootstrap): New variable.
---
 gnu/packages/groovy.scm | 75 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/gnu/packages/groovy.scm b/gnu/packages/groovy.scm
index ee2894e30..016d7e66b 100644
--- a/gnu/packages/groovy.scm
+++ b/gnu/packages/groovy.scm
@@ -93,3 +93,78 @@
 groovy submodules.")
     (license (list license:gpl2
                    license:cddl1.1))))
+
+(define groovy-bootstrap
+  (package
+    (inherit groovy-java-bootstrap)
+    (name "groovy-bootstrap")
+    (arguments
+     `(#:jar-name "groovy.jar"
+       #:jdk ,icedtea-8
+       ;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)"))))
+         (add-before 'build 'generate-parser
+           (lambda _
+             (with-directory-excursion "src/main/org/codehaus/groovy/antlr/java"
+               (zero? (system* "antlr" "java.g")))
+             (with-directory-excursion "src/main/org/codehaus/groovy/antlr"
+               (mkdir "parser")
+               (with-directory-excursion "parser"
+                 (zero? (system* "antlr" "../groovy.g"))))))
+         (add-before 'build 'generate-exception-utils
+           (lambda _
+             (system* "javac" "-cp" (getenv "CLASSPATH")
+                      "config/ant/src/org/codehaus/groovy/ExceptionUtilsGenerator.java")
+             (zero? (system* "java" "-cp" (string-append (getenv "CLASSPATH")
+                                                         ":config/ant/src")
+                             "org.codehaus.groovy.ExceptionUtilsGenerator"
+                             "target/classes/org/codehaus/groovy/runtime/ExceptionUtils.class"))))
+         (add-before 'build 'generate-dgminfo
+           (lambda _
+             (mkdir-p "target/classes/org/codehaus/groovy/runtime")
+             (mkdir-p "target/classes/META-INF")
+             (system* "javac" "-cp" (getenv "CLASSPATH")
+                      "src/main/org/codehaus/groovy/tools/DgmConverter.java")
+             (zero? (system* "java" "-cp" (string-append (getenv "CLASSPATH")
+                                                         ":src/main")
+                             "org.codehaus.groovy.tools.DgmConverter"))))
+         (add-before 'build 'copy-resources
+           (lambda _
+             (with-directory-excursion "src/main"
+               (for-each (lambda (file)
+                           (mkdir-p (string-append "../../target/classes/"
+                                                   (dirname file)))
+                           (copy-file file
+                                      (string-append "../../target/classes/"
+                                                     file)))
+                  (find-files "." ".*.(txt|properties|xml|html)")))))
+         (replace 'build
+           (lambda _
+             (mkdir-p "build/jar")
+             (and
+               (zero? (apply system* "java" "-cp" (getenv "CLASSPATH")
+                               "org.codehaus.groovy.tools.FileSystemCompiler"
+                               "-d" "target/classes"
+                               "-j"; joint compilation
+                               (find-files "src/main"
+                                           ".*\\.(groovy|java)$")))
+               (zero? (system* "jar" "-cf" "build/jar/groovy.jar"
+                               "-C" "target/classes" "."))))))))
+    (inputs
+     `(("java-apache-ivy" ,java-apache-ivy)
+       ,@(package-inputs groovy-java-bootstrap)))
+    (native-inputs
+     `(("groovy-java-bootstrap" ,groovy-java-bootstrap)
+       ,@(package-native-inputs groovy-java-bootstrap)))
+    (synopsis "Groovy compiler")
+    (description "This package contains the first version of the Groovy compiler.
+Although already usable, it doesn't contain the groovy library yet.  This package
+is used to build the groovy submodules written in groovy.")))
-- 
2.17.0