Commit | Line | Data |
---|---|---|
fdc9170b JL |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
7 | ;;; under the terms of the GNU General Public License as published by | |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | (define-module (gnu packages groovy) | |
20 | #:use-module ((guix licenses) #:prefix license:) | |
21 | #:use-module (guix packages) | |
22 | #:use-module (guix download) | |
23 | #:use-module (guix utils) | |
24 | #:use-module (guix build-system ant) | |
25 | #:use-module (gnu packages) | |
26 | #:use-module (gnu packages java) | |
27 | #:use-module (gnu packages xml)) | |
28 | ||
29 | (define java-groovy-bootstrap | |
30 | (package | |
b0192c85 | 31 | (name "java-groovy-bootstrap") |
fdc9170b JL |
32 | (version "2.4.15") |
33 | (source (origin | |
34 | (method url-fetch) | |
35 | (uri (string-append "https://github.com/apache/groovy/archive/GROOVY_" | |
36 | (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version) | |
37 | ".tar.gz")) | |
38 | (file-name (string-append name "-" version ".tar.gz")) | |
39 | (sha256 | |
40 | (base32 | |
41 | "19f3yd2z6jmz1xhwi5kkg1wmgbqkfs7qvd3rzb43xr3nffz8cisv")) | |
42 | (patches | |
43 | (search-patches | |
44 | "groovy-add-exceptionutilsgenerator.patch")))) | |
45 | (build-system ant-build-system) | |
46 | (arguments | |
47 | `(#:jar-name "groovy.jar" | |
48 | #:source-dir "src/main:subprojects/groovy-test/src/main/java" | |
49 | #:test-dir "src/test" | |
50 | #:tests? #f | |
51 | #:jdk ,icedtea-8 | |
52 | #:main-class "groovy.ui.GroovyMain" | |
53 | #:phases | |
54 | (modify-phases %standard-phases | |
55 | (add-before 'build 'fix-java8 | |
56 | ;; Fix "Reference to plus is ambiguous" | |
57 | (lambda _ | |
58 | (substitute* "src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java" | |
59 | (("toList\\(left\\)") | |
60 | "(List<T>)toList(left)")) | |
61 | #t)) | |
62 | (add-before 'build 'generate-parsers | |
63 | (lambda _ | |
64 | (with-directory-excursion "src/main/org/codehaus/groovy/antlr/java" | |
65 | (invoke "antlr" "java.g")) | |
66 | (with-directory-excursion "src/main/org/codehaus/groovy/antlr" | |
67 | (mkdir "parser") | |
68 | (with-directory-excursion "parser" | |
69 | (invoke "antlr" "../groovy.g"))) | |
70 | #t)) | |
71 | (add-before 'build 'generate-exception-utils | |
72 | (lambda _ | |
73 | (invoke "javac" "-cp" (getenv "CLASSPATH") | |
74 | "config/ant/src/org/codehaus/groovy/ExceptionUtilsGenerator.java") | |
75 | (invoke "java" "-cp" (string-append (getenv "CLASSPATH") | |
76 | ":config/ant/src") | |
77 | "org.codehaus.groovy.ExceptionUtilsGenerator" | |
78 | "build/classes/org/codehaus/groovy/runtime/ExceptionUtils.class") | |
79 | #t))))) | |
80 | (native-inputs | |
81 | `(("java-junit" ,java-junit) | |
82 | ("java-hamcrest-core" ,java-hamcrest-core) | |
83 | ("antlr2" ,antlr2) | |
84 | ("java-jmock-1" ,java-jmock-1) | |
85 | ("java-xmlunit-legacy" ,java-xmlunit-legacy))) | |
86 | (inputs | |
87 | `(("java-commons-cli" ,java-commons-cli) | |
88 | ("java-asm" ,java-asm) | |
89 | ("java-classpathx-servletapi" ,java-classpathx-servletapi) | |
90 | ("java-xstream" ,java-xstream) | |
91 | ("java-jansi" ,java-jansi) | |
92 | ("java-jline-2" ,java-jline-2))) | |
93 | (home-page "http://groovy-lang.org/") | |
94 | (synopsis "Groovy's java bootstrap") | |
95 | (description "This package contains the java bootstrap that is used to build | |
96 | groovy submodules.") | |
97 | (license license:asl2.0))) | |
b0192c85 JL |
98 | |
99 | (define groovy-bootstrap | |
100 | (package | |
101 | (inherit java-groovy-bootstrap) | |
102 | (name "groovy-bootstrap") | |
103 | (arguments | |
104 | `(#:jar-name "groovy.jar" | |
105 | #:jdk ,icedtea-8 | |
106 | ;Requires groovy-xml and logback-classic which are circular dependencies | |
107 | #:tests? #f | |
108 | #:phases | |
109 | (modify-phases %standard-phases | |
110 | (add-before 'build 'fix-java8 | |
111 | ;; Fix "Reference to plus is ambiguous" | |
112 | (lambda _ | |
113 | (substitute* "src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java" | |
114 | (("toList\\(left\\)") | |
115 | "(List<T>)toList(left)")) | |
116 | #t)) | |
117 | (add-before 'build 'generate-parser | |
118 | (lambda _ | |
119 | (with-directory-excursion "src/main/org/codehaus/groovy/antlr/java" | |
120 | (invoke "antlr" "java.g")) | |
121 | (with-directory-excursion "src/main/org/codehaus/groovy/antlr" | |
122 | (mkdir "parser") | |
123 | (with-directory-excursion "parser" | |
124 | (invoke "antlr" "../groovy.g"))) | |
125 | #t)) | |
126 | (add-before 'build 'generate-exception-utils | |
127 | (lambda _ | |
128 | (invoke "javac" "-cp" (getenv "CLASSPATH") | |
129 | "config/ant/src/org/codehaus/groovy/ExceptionUtilsGenerator.java") | |
130 | (invoke "java" "-cp" (string-append (getenv "CLASSPATH") | |
131 | ":config/ant/src") | |
132 | "org.codehaus.groovy.ExceptionUtilsGenerator" | |
133 | "target/classes/org/codehaus/groovy/runtime/ExceptionUtils.class") | |
134 | #t)) | |
135 | (add-before 'build 'generate-dgminfo | |
136 | (lambda _ | |
137 | (mkdir-p "target/classes/org/codehaus/groovy/runtime") | |
138 | (mkdir-p "target/classes/META-INF") | |
139 | (invoke "javac" "-cp" (getenv "CLASSPATH") | |
140 | "src/main/org/codehaus/groovy/tools/DgmConverter.java") | |
141 | (invoke "java" "-cp" (string-append (getenv "CLASSPATH") | |
142 | ":src/main") | |
143 | "org.codehaus.groovy.tools.DgmConverter") | |
144 | #t)) | |
145 | (add-before 'build 'copy-resources | |
146 | (lambda _ | |
147 | (with-directory-excursion "src/main" | |
148 | (for-each (lambda (file) | |
149 | (mkdir-p (string-append "../../target/classes/" | |
150 | (dirname file))) | |
151 | (copy-file file | |
152 | (string-append "../../target/classes/" | |
153 | file))) | |
154 | (find-files "." ".*.(txt|properties|xml|html)"))) | |
155 | #t)) | |
156 | (replace 'build | |
157 | (lambda _ | |
158 | (mkdir-p "build/jar") | |
159 | (apply invoke "java" "-cp" (getenv "CLASSPATH") | |
160 | "org.codehaus.groovy.tools.FileSystemCompiler" | |
161 | "-d" "target/classes" | |
162 | "-j"; joint compilation | |
163 | (find-files "src/main" | |
164 | ".*\\.(groovy|java)$")) | |
165 | (invoke "jar" "-cf" "build/jar/groovy.jar" | |
166 | "-C" "target/classes" ".") | |
167 | #t))))) | |
168 | (inputs | |
169 | `(("java-apache-ivy" ,java-apache-ivy) | |
170 | ,@(package-inputs java-groovy-bootstrap))) | |
171 | (native-inputs | |
172 | `(("java-groovy-bootstrap" ,java-groovy-bootstrap) | |
173 | ,@(package-native-inputs java-groovy-bootstrap))) | |
174 | (synopsis "Groovy compiler") | |
175 | (description "This package contains the first version of the Groovy compiler. | |
176 | Although already usable, it doesn't contain the groovy library yet. This package | |
177 | is used to build the groovy submodules written in groovy."))) |