7387235c5bb0452f0f2cd8ff6a1ae5dd57bae632
[jackhill/guix/guix.git] / gnu / packages / java.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
4 ;;; Copyright © 2016 Roel Janssen <roel@gnu.org>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages java)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix utils)
26 #:use-module (guix build-system ant)
27 #:use-module (guix build-system gnu)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages attr)
30 #:use-module (gnu packages autotools)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages bash)
33 #:use-module (gnu packages certs)
34 #:use-module (gnu packages cpio)
35 #:use-module (gnu packages cups)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages fontutils)
38 #:use-module (gnu packages gawk)
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages gl)
41 #:use-module (gnu packages gnuzilla) ;nss
42 #:use-module (gnu packages ghostscript) ;lcms
43 #:use-module (gnu packages gnome)
44 #:use-module (gnu packages gtk)
45 #:use-module (gnu packages image)
46 #:use-module (gnu packages linux) ;alsa
47 #:use-module (gnu packages wget)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages perl)
50 #:use-module (gnu packages mit-krb5)
51 #:use-module (gnu packages xml)
52 #:use-module (gnu packages xorg)
53 #:use-module (gnu packages zip)
54 #:use-module (gnu packages texinfo)
55 #:use-module ((srfi srfi-1) #:select (fold alist-delete))
56 #:use-module (srfi srfi-11)
57 #:use-module (ice-9 match))
58
59 (define-public java-swt
60 (package
61 (name "java-swt")
62 (version "4.6")
63 (source
64 ;; The types of many variables and procedures differ in the sources
65 ;; dependent on whether the target architecture is a 32-bit system or a
66 ;; 64-bit system. Instead of patching the sources on demand in a build
67 ;; phase we download either the 32-bit archive (which mostly uses "int"
68 ;; types) or the 64-bit archive (which mostly uses "long" types).
69 (let ((hash32 "0jmx1h65wqxsyjzs64i2z6ryiynllxzm13cq90fky2qrzagcw1ir")
70 (hash64 "0wnd01xssdq9pgx5xqh5lfiy3dmk60dzzqdxzdzf883h13692lgy")
71 (file32 "x86")
72 (file64 "x86_64"))
73 (let-values (((hash file)
74 (match (or (%current-target-system) (%current-system))
75 ("x86_64-linux" (values hash64 file64))
76 (_ (values hash32 file32)))))
77 (origin
78 (method url-fetch)
79 (uri (string-append
80 "http://ftp-stud.fht-esslingen.de/pub/Mirrors/"
81 "eclipse/eclipse/downloads/drops4/R-" version
82 "-201606061100/swt-" version "-gtk-linux-" file ".zip"))
83 (sha256 (base32 hash))))))
84 (build-system ant-build-system)
85 (arguments
86 `(#:jar-name "swt.jar"
87 #:tests? #f ; no "check" target
88 #:phases
89 (modify-phases %standard-phases
90 (replace 'unpack
91 (lambda* (#:key source #:allow-other-keys)
92 (and (mkdir "swt")
93 (zero? (system* "unzip" source "-d" "swt"))
94 (chdir "swt")
95 (mkdir "src")
96 (zero? (system* "unzip" "src.zip" "-d" "src")))))
97 ;; The classpath contains invalid icecat jars. Since we don't need
98 ;; anything other than the JDK on the classpath, we can simply unset
99 ;; it.
100 (add-after 'configure 'unset-classpath
101 (lambda _ (unsetenv "CLASSPATH") #t))
102 (add-before 'build 'build-native
103 (lambda* (#:key inputs outputs #:allow-other-keys)
104 (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
105 ;; Build shared libraries. Users of SWT have to set the system
106 ;; property swt.library.path to the "lib" directory of this
107 ;; package output.
108 (mkdir-p lib)
109 (setenv "OUTPUT_DIR" lib)
110 (with-directory-excursion "src"
111 (zero? (system* "bash" "build.sh"))))))
112 (add-after 'install 'install-native
113 (lambda* (#:key outputs #:allow-other-keys)
114 (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
115 (for-each (lambda (file)
116 (install-file file lib))
117 (find-files "." "\\.so$"))
118 #t))))))
119 (inputs
120 `(("xulrunner" ,icecat)
121 ("gtk" ,gtk+-2)
122 ("libxtst" ,libxtst)
123 ("libxt" ,libxt)
124 ("mesa" ,mesa)
125 ("glu" ,glu)))
126 (native-inputs
127 `(("pkg-config" ,pkg-config)
128 ("unzip" ,unzip)))
129 (home-page "https://www.eclipse.org/swt/")
130 (synopsis "Widget toolkit for Java")
131 (description
132 "SWT is a widget toolkit for Java designed to provide efficient, portable
133 access to the user-interface facilities of the operating systems on which it
134 is implemented.")
135 ;; SWT code is licensed under EPL1.0
136 ;; Gnome and Gtk+ bindings contain code licensed under LGPLv2.1
137 ;; Cairo bindings contain code under MPL1.1
138 ;; XULRunner 1.9 bindings contain code under MPL2.0
139 (license (list
140 license:epl1.0
141 license:mpl1.1
142 license:mpl2.0
143 license:lgpl2.1+))))
144
145 (define-public clojure
146 (let* ((remove-archives '(begin
147 (for-each delete-file
148 (find-files "." ".*\\.(jar|zip)"))
149 #t))
150 (submodule (lambda (prefix version hash)
151 (origin
152 (method url-fetch)
153 (uri (string-append "https://github.com/clojure/"
154 prefix version ".tar.gz"))
155 (sha256 (base32 hash))
156 (modules '((guix build utils)))
157 (snippet remove-archives)))))
158 (package
159 (name "clojure")
160 (version "1.8.0")
161 (source
162 (origin
163 (method url-fetch)
164 (uri
165 (string-append "http://repo1.maven.org/maven2/org/clojure/clojure/"
166 version "/clojure-" version ".zip"))
167 (sha256
168 (base32 "1nip095fz5c492sw15skril60i1vd21ibg6szin4jcvyy3xr6cym"))
169 (modules '((guix build utils)))
170 (snippet remove-archives)))
171 (build-system ant-build-system)
172 (arguments
173 `(#:modules ((guix build ant-build-system)
174 (guix build utils)
175 (ice-9 ftw)
176 (ice-9 regex)
177 (srfi srfi-1)
178 (srfi srfi-26))
179 #:test-target "test"
180 #:phases
181 (modify-phases %standard-phases
182 (add-after 'unpack 'unpack-submodule-sources
183 (lambda* (#:key inputs #:allow-other-keys)
184 (for-each
185 (lambda (name)
186 (mkdir-p name)
187 (with-directory-excursion name
188 (or (zero? (system* "tar"
189 ;; Use xz for repacked tarball.
190 "--xz"
191 "--extract"
192 "--verbose"
193 "--file" (assoc-ref inputs name)
194 "--strip-components=1"))
195 (error "failed to unpack tarball" name)))
196 (copy-recursively (string-append name "/src/main/clojure/")
197 "src/clj/"))
198 '("data-generators-src"
199 "java-classpath-src"
200 "test-check-src"
201 "test-generative-src"
202 "tools-namespace-src"
203 "tools-reader-src"))
204 #t))
205 ;; The javadoc target is not built by default.
206 (add-after 'build 'build-doc
207 (lambda _
208 (zero? (system* "ant" "javadoc"))))
209 ;; Needed since no install target is provided.
210 (replace 'install
211 (lambda* (#:key outputs #:allow-other-keys)
212 (let ((java-dir (string-append (assoc-ref outputs "out")
213 "/share/java/")))
214 ;; Install versioned to avoid collisions.
215 (install-file (string-append "clojure-" ,version ".jar")
216 java-dir)
217 #t)))
218 ;; Needed since no install-doc target is provided.
219 (add-after 'install 'install-doc
220 (lambda* (#:key outputs #:allow-other-keys)
221 (let ((doc-dir (string-append (assoc-ref outputs "out")
222 "/share/doc/clojure-"
223 ,version "/")))
224 (copy-recursively "doc/clojure" doc-dir)
225 (copy-recursively "target/javadoc/"
226 (string-append doc-dir "javadoc/"))
227 (for-each (cut install-file <> doc-dir)
228 (filter (cut string-match
229 ".*\\.(html|markdown|md|txt)"
230 <>)
231 (scandir "./")))
232 #t))))))
233 ;; The native-inputs below are needed to run the tests.
234 (native-inputs
235 `(("data-generators-src"
236 ,(submodule "data.generators/archive/data.generators-"
237 "0.1.2"
238 "0kki093jp4ckwxzfnw8ylflrfqs8b1i1wi9iapmwcsy328dmgzp1"))
239 ("java-classpath-src"
240 ,(submodule "java.classpath/archive/java.classpath-"
241 "0.2.3"
242 "0sjymly9xh1lkvwn5ygygpsfwz4dabblnlq0c9bx76rkvq62fyng"))
243 ("test-check-src"
244 ,(submodule "test.check/archive/test.check-"
245 "0.9.0"
246 "0p0mnyhr442bzkz0s4k5ra3i6l5lc7kp6ajaqkkyh4c2k5yck1md"))
247 ("test-generative-src"
248 ,(submodule "test.generative/archive/test.generative-"
249 "0.5.2"
250 "1pjafy1i7yblc7ixmcpfq1lfbyf3jaljvkgrajn70sws9xs7a9f8"))
251 ("tools-namespace-src"
252 ,(submodule "tools.namespace/archive/tools.namespace-"
253 "0.2.11"
254 "10baak8v0hnwz2hr33bavshm7y49mmn9zsyyms1dwjz45p5ymhy0"))
255 ("tools-reader-src"
256 ,(submodule "tools.reader/archive/tools.reader-"
257 "0.10.0"
258 "09i3lzbhr608h76mhdjm3932gg9xi8sflscla3c5f0v1nkc28cnr"))))
259 (home-page "https://clojure.org/")
260 (synopsis "Lisp dialect running on the JVM")
261 (description "Clojure is a dynamic, general-purpose programming language,
262 combining the approachability and interactive development of a scripting
263 language with an efficient and robust infrastructure for multithreaded
264 programming. Clojure is a compiled language, yet remains completely dynamic
265 – every feature supported by Clojure is supported at runtime. Clojure
266 provides easy access to the Java frameworks, with optional type hints and type
267 inference, to ensure that calls to Java can avoid reflection.
268
269 Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy
270 and a powerful macro system. Clojure is predominantly a functional programming
271 language, and features a rich set of immutable, persistent data structures.
272 When mutable state is needed, Clojure offers a software transactional memory
273 system and reactive Agent system that ensure clean, correct, multithreaded
274 designs.")
275 ;; Clojure is licensed under EPL1.0
276 ;; ASM bytecode manipulation library is licensed under BSD-3
277 ;; Guava Murmur3 hash implementation is licensed under APL2.0
278 ;; src/clj/repl.clj is licensed under CPL1.0
279 ;;
280 ;; See readme.html or readme.txt for details.
281 (license (list license:epl1.0
282 license:bsd-3
283 license:asl2.0
284 license:cpl1.0)))))
285
286 (define-public ant
287 (package
288 (name "ant")
289 (version "1.9.6")
290 (source (origin
291 (method url-fetch)
292 (uri (string-append "mirror://apache/ant/source/apache-ant-"
293 version "-src.tar.gz"))
294 (sha256
295 (base32
296 "1396wflczyxjxl603dhxjvd559f289lha9y2f04f71c7hapjl3am"))))
297 (build-system gnu-build-system)
298 (arguments
299 `(#:tests? #f ; no "check" target
300 #:phases
301 (alist-cons-after
302 'unpack 'remove-scripts
303 ;; Remove bat / cmd scripts for DOS as well as the antRun and runant
304 ;; wrappers.
305 (lambda _
306 (for-each delete-file
307 (find-files "src/script"
308 "(.*\\.(bat|cmd)|runant.*|antRun.*)")))
309 (alist-replace
310 'build
311 (lambda _
312 (setenv "JAVA_HOME" (string-append (assoc-ref %build-inputs "gcj")
313 "/lib/jvm"))
314 ;; Disable tests to avoid dependency on hamcrest-core, which needs
315 ;; Ant to build. This is necessary in addition to disabling the
316 ;; "check" phase, because the dependency on "test-jar" would always
317 ;; result in the tests to be run.
318 (substitute* "build.xml"
319 (("depends=\"jars,test-jar\"") "depends=\"jars\""))
320 (zero? (system* "bash" "bootstrap.sh"
321 (string-append "-Ddist.dir="
322 (assoc-ref %outputs "out")))))
323 (alist-delete
324 'configure
325 (alist-delete 'install %standard-phases))))))
326 (native-inputs
327 `(("gcj" ,gcj)))
328 (home-page "http://ant.apache.org")
329 (synopsis "Build tool for Java")
330 (description
331 "Ant is a platform-independent build tool for Java. It is similar to
332 make but is implemented using the Java language, requires the Java platform,
333 and is best suited to building Java projects. Ant uses XML to describe the
334 build process and its dependencies, whereas Make uses Makefile format.")
335 (license license:asl2.0)))
336
337 (define-public icedtea-6
338 (package
339 (name "icedtea")
340 (version "1.13.12")
341 (source (origin
342 (method url-fetch)
343 (uri (string-append
344 "http://icedtea.wildebeest.org/download/source/icedtea6-"
345 version ".tar.xz"))
346 (sha256
347 (base32
348 "1q5iqm3dzqj8w3dwj6qqhczkkrslrfhmn3110klfwq9kyi2nimj8"))
349 (modules '((guix build utils)))
350 (snippet
351 '(substitute* "Makefile.in"
352 ;; link against libgcj to avoid linker error
353 (("-o native-ecj")
354 "-lgcj -o native-ecj")
355 ;; do not leak information about the build host
356 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
357 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
358 (build-system gnu-build-system)
359 (outputs '("out" ; Java Runtime Environment
360 "jdk" ; Java Development Kit
361 "doc")) ; all documentation
362 (arguments
363 `(;; There are many failing tests and many are known to fail upstream.
364 ;;
365 ;; * Hotspot VM tests:
366 ;; FAILED: compiler/7082949/Test7082949.java
367 ;; FAILED: compiler/7088020/Test7088020.java
368 ;; FAILED: runtime/6929067/Test6929067.sh
369 ;; FAILED: serviceability/sa/jmap-hashcode/Test8028623.java
370 ;; => Test results: passed: 161; failed: 4
371 ;;
372 ;; * langtools tests:
373 ;; FAILED: com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
374 ;; FAILED: tools/javac/6627362/T6627362.java
375 ;; FAILED: tools/javac/7003595/T7003595.java
376 ;; FAILED: tools/javac/7024568/T7024568.java
377 ;; FAILED: tools/javap/4111861/T4111861.java
378 ;; FAILED: tools/javap/ListTest.java
379 ;; FAILED: tools/javap/OptionTest.java
380 ;; FAILED: tools/javap/T4884240.java
381 ;; FAILED: tools/javap/T4975569.java
382 ;; --> fails because of insignificant whitespace differences
383 ;; in output of javap
384 ;; FAILED: tools/javap/T6868539.java
385 ;; => Test results: passed: 1,445; failed: 10
386 ;;
387 ;; * JDK tests:
388 ;; Tests are incomplete because of a segfault after this test:
389 ;; javax/crypto/spec/RC5ParameterSpec/RC5ParameterSpecEquals.java
390 ;; A bug report has already been filed upstream:
391 ;; http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2188
392 ;;
393 ;; The tests require xvfb-run, a wrapper script around Xvfb, which
394 ;; has not been packaged yet. Without it many AWT tests fail, so I
395 ;; made no attempts to make a list of failing JDK tests. At least
396 ;; 222 tests are failing of which at least 132 are AWT tests.
397 #:tests? #f
398
399 ;; The DSOs use $ORIGIN to refer to each other, but (guix build
400 ;; gremlin) doesn't support it yet, so skip this phase.
401 #:validate-runpath? #f
402
403 #:modules ((guix build utils)
404 (guix build gnu-build-system)
405 (ice-9 popen)
406 (ice-9 rdelim)
407 (srfi srfi-19))
408
409 #:configure-flags
410 (let* ((gcjdir (assoc-ref %build-inputs "gcj"))
411 (ecj (string-append gcjdir "/share/java/ecj.jar"))
412 (jdk (string-append gcjdir "/lib/jvm/"))
413 (gcj (string-append gcjdir "/bin/gcj")))
414 `("--enable-bootstrap"
415 "--enable-nss"
416 "--without-rhino"
417 "--disable-downloading"
418 "--disable-tests" ;they are run in the check phase instead
419 "--with-openjdk-src-dir=./openjdk.src"
420 ,(string-append "--with-javac=" jdk "/bin/javac")
421 ,(string-append "--with-ecj-jar=" ecj)
422 ,(string-append "--with-gcj=" gcj)
423 ,(string-append "--with-jdk-home=" jdk)
424 ,(string-append "--with-java=" jdk "/bin/java")))
425 #:phases
426 (modify-phases %standard-phases
427 (replace 'unpack
428 (lambda* (#:key source inputs #:allow-other-keys)
429 (and (zero? (system* "tar" "xvf" source))
430 (begin
431 (chdir (string-append "icedtea6-" ,version))
432 (mkdir "openjdk.src")
433 (with-directory-excursion "openjdk.src"
434 (copy-file (assoc-ref inputs "openjdk6-src")
435 "openjdk6-src.tar.xz")
436 (zero? (system* "tar" "xvf" "openjdk6-src.tar.xz")))))))
437 (add-after 'unpack 'patch-patches
438 (lambda _
439 ;; shebang in patches so that they apply cleanly
440 (substitute* '("patches/jtreg-jrunscript.patch"
441 "patches/hotspot/hs23/drop_unlicensed_test.patch")
442 (("#!/bin/sh") (string-append "#!" (which "sh"))))
443 #t))
444 (add-after 'unpack 'patch-paths
445 (lambda _
446 ;; buildtree.make generates shell scripts, so we need to replace
447 ;; the generated shebang
448 (substitute* '("openjdk.src/hotspot/make/linux/makefiles/buildtree.make")
449 (("/bin/sh") (which "bash")))
450
451 (let ((corebin (string-append
452 (assoc-ref %build-inputs "coreutils") "/bin/"))
453 (binbin (string-append
454 (assoc-ref %build-inputs "binutils") "/bin/"))
455 (grepbin (string-append
456 (assoc-ref %build-inputs "grep") "/bin/")))
457 (substitute* '("openjdk.src/jdk/make/common/shared/Defs-linux.gmk"
458 "openjdk.src/corba/make/common/shared/Defs-linux.gmk")
459 (("UNIXCOMMAND_PATH = /bin/")
460 (string-append "UNIXCOMMAND_PATH = " corebin))
461 (("USRBIN_PATH = /usr/bin/")
462 (string-append "USRBIN_PATH = " corebin))
463 (("DEVTOOLS_PATH *= */usr/bin/")
464 (string-append "DEVTOOLS_PATH = " corebin))
465 (("COMPILER_PATH *= */usr/bin/")
466 (string-append "COMPILER_PATH = "
467 (assoc-ref %build-inputs "gcc") "/bin/"))
468 (("DEF_OBJCOPY *=.*objcopy")
469 (string-append "DEF_OBJCOPY = " (which "objcopy"))))
470
471 ;; fix path to alsa header
472 (substitute* "openjdk.src/jdk/make/common/shared/Sanity.gmk"
473 (("ALSA_INCLUDE=/usr/include/alsa/version.h")
474 (string-append "ALSA_INCLUDE="
475 (assoc-ref %build-inputs "alsa-lib")
476 "/include/alsa/version.h")))
477
478 ;; fix hard-coded utility paths
479 (substitute* '("openjdk.src/jdk/make/common/shared/Defs-utils.gmk"
480 "openjdk.src/corba/make/common/shared/Defs-utils.gmk")
481 (("ECHO *=.*echo")
482 (string-append "ECHO = " (which "echo")))
483 (("^GREP *=.*grep")
484 (string-append "GREP = " (which "grep")))
485 (("EGREP *=.*egrep")
486 (string-append "EGREP = " (which "egrep")))
487 (("CPIO *=.*cpio")
488 (string-append "CPIO = " (which "cpio")))
489 (("READELF *=.*readelf")
490 (string-append "READELF = " (which "readelf")))
491 (("^ *AR *=.*ar")
492 (string-append "AR = " (which "ar")))
493 (("^ *TAR *=.*tar")
494 (string-append "TAR = " (which "tar")))
495 (("AS *=.*as")
496 (string-append "AS = " (which "as")))
497 (("LD *=.*ld")
498 (string-append "LD = " (which "ld")))
499 (("STRIP *=.*strip")
500 (string-append "STRIP = " (which "strip")))
501 (("NM *=.*nm")
502 (string-append "NM = " (which "nm")))
503 (("^SH *=.*sh")
504 (string-append "SH = " (which "bash")))
505 (("^FIND *=.*find")
506 (string-append "FIND = " (which "find")))
507 (("LDD *=.*ldd")
508 (string-append "LDD = " (which "ldd")))
509 (("NAWK *=.*(n|g)awk")
510 (string-append "NAWK = " (which "gawk")))
511 (("XARGS *=.*xargs")
512 (string-append "XARGS = " (which "xargs")))
513 (("UNZIP *=.*unzip")
514 (string-append "UNZIP = " (which "unzip")))
515 (("ZIPEXE *=.*zip")
516 (string-append "ZIPEXE = " (which "zip")))
517 (("SED *=.*sed")
518 (string-append "SED = " (which "sed"))))
519
520 ;; Some of these timestamps cause problems as they are more than
521 ;; 10 years ago, failing the build process.
522 (substitute*
523 "openjdk.src/jdk/src/share/classes/java/util/CurrencyData.properties"
524 (("AZ=AZM;2005-12-31-20-00-00;AZN") "AZ=AZN")
525 (("MZ=MZM;2006-06-30-22-00-00;MZN") "MZ=MZN")
526 (("RO=ROL;2005-06-30-21-00-00;RON") "RO=RON")
527 (("TR=TRL;2004-12-31-22-00-00;TRY") "TR=TRY")))))
528 (add-before 'configure 'set-additional-paths
529 (lambda* (#:key inputs #:allow-other-keys)
530 (let* ((gcjdir (assoc-ref %build-inputs "gcj"))
531 (gcjlib (string-append gcjdir "/lib"))
532 ;; Get target-specific include directory so that
533 ;; libgcj-config.h is found when compiling hotspot.
534 (gcjinclude (let* ((port (open-input-pipe "gcj -print-file-name=include"))
535 (str (read-line port)))
536 (close-pipe port)
537 str)))
538 (setenv "CPATH"
539 (string-append gcjinclude ":"
540 (assoc-ref %build-inputs "libxrender")
541 "/include/X11/extensions" ":"
542 (assoc-ref %build-inputs "libxtst")
543 "/include/X11/extensions" ":"
544 (assoc-ref %build-inputs "libxinerama")
545 "/include/X11/extensions" ":"
546 (or (getenv "CPATH") "")))
547 (setenv "ALT_CUPS_HEADERS_PATH"
548 (string-append (assoc-ref %build-inputs "cups")
549 "/include"))
550 (setenv "ALT_FREETYPE_HEADERS_PATH"
551 (string-append (assoc-ref %build-inputs "freetype")
552 "/include"))
553 (setenv "ALT_FREETYPE_LIB_PATH"
554 (string-append (assoc-ref %build-inputs "freetype")
555 "/lib")))))
556 (add-before 'check 'fix-test-framework
557 (lambda _
558 ;; Fix PATH in test environment
559 (substitute* "src/jtreg/com/sun/javatest/regtest/Main.java"
560 (("PATH=/bin:/usr/bin")
561 (string-append "PATH=" (getenv "PATH"))))
562 (substitute* "src/jtreg/com/sun/javatest/util/SysEnv.java"
563 (("/usr/bin/env") (which "env")))
564 #t))
565 (add-before 'check 'fix-hotspot-tests
566 (lambda _
567 (with-directory-excursion "openjdk.src/hotspot/test/"
568 (substitute* "jprt.config"
569 (("PATH=\"\\$\\{path4sdk\\}\"")
570 (string-append "PATH=" (getenv "PATH")))
571 (("make=/usr/bin/make")
572 (string-append "make=" (which "make"))))
573 (substitute* '("runtime/6626217/Test6626217.sh"
574 "runtime/7110720/Test7110720.sh")
575 (("/bin/rm") (which "rm"))
576 (("/bin/cp") (which "cp"))
577 (("/bin/mv") (which "mv"))))
578 #t))
579 (add-before 'check 'fix-jdk-tests
580 (lambda _
581 (with-directory-excursion "openjdk.src/jdk/test/"
582 (substitute* "com/sun/jdi/JdbReadTwiceTest.sh"
583 (("/bin/pwd") (which "pwd")))
584 (substitute* "com/sun/jdi/ShellScaffold.sh"
585 (("/bin/kill") (which "kill")))
586 (substitute* "start-Xvfb.sh"
587 ;;(("/usr/bin/X11/Xvfb") (which "Xvfb"))
588 (("/usr/bin/nohup") (which "nohup")))
589 (substitute* "javax/security/auth/Subject/doAs/Test.sh"
590 (("/bin/rm") (which "rm")))
591 (substitute* "tools/launcher/MultipleJRE.sh"
592 (("echo \"#!/bin/sh\"")
593 (string-append "echo \"#!" (which "rm") "\""))
594 (("/usr/bin/zip") (which "zip")))
595 (substitute* "com/sun/jdi/OnThrowTest.java"
596 (("#!/bin/sh") (string-append "#!" (which "sh"))))
597 (substitute* "java/lang/management/OperatingSystemMXBean/GetSystemLoadAverage.java"
598 (("/usr/bin/uptime") (which "uptime")))
599 (substitute* "java/lang/ProcessBuilder/Basic.java"
600 (("/usr/bin/env") (which "env"))
601 (("/bin/false") (which "false"))
602 (("/bin/true") (which "true"))
603 (("/bin/cp") (which "cp"))
604 (("/bin/sh") (which "sh")))
605 (substitute* "java/lang/ProcessBuilder/FeelingLucky.java"
606 (("/bin/sh") (which "sh")))
607 (substitute* "java/lang/ProcessBuilder/Zombies.java"
608 (("/usr/bin/perl") (which "perl"))
609 (("/bin/ps") (which "ps"))
610 (("/bin/true") (which "true")))
611 (substitute* "java/lang/Runtime/exec/ConcurrentRead.java"
612 (("/usr/bin/tee") (which "tee")))
613 (substitute* "java/lang/Runtime/exec/ExecWithDir.java"
614 (("/bin/true") (which "true")))
615 (substitute* "java/lang/Runtime/exec/ExecWithInput.java"
616 (("/bin/cat") (which "cat")))
617 (substitute* "java/lang/Runtime/exec/ExitValue.java"
618 (("/bin/sh") (which "sh"))
619 (("/bin/true") (which "true"))
620 (("/bin/kill") (which "kill")))
621 (substitute* "java/lang/Runtime/exec/LotsOfDestroys.java"
622 (("/usr/bin/echo") (which "echo")))
623 (substitute* "java/lang/Runtime/exec/LotsOfOutput.java"
624 (("/usr/bin/cat") (which "cat")))
625 (substitute* "java/lang/Runtime/exec/SleepyCat.java"
626 (("/bin/cat") (which "cat"))
627 (("/bin/sleep") (which "sleep"))
628 (("/bin/sh") (which "sh")))
629 (substitute* "java/lang/Runtime/exec/StreamsSurviveDestroy.java"
630 (("/bin/cat") (which "cat")))
631 (substitute* "java/rmi/activation/CommandEnvironment/SetChildEnv.java"
632 (("/bin/chmod") (which "chmod")))
633 (substitute* "java/util/zip/ZipFile/Assortment.java"
634 (("/bin/sh") (which "sh"))))
635 #t))
636 (replace 'check
637 (lambda _
638 ;; The "make check-*" targets always return zero, so we need to
639 ;; check for errors in the associated log files to determine
640 ;; whether any tests have failed.
641 (use-modules (ice-9 rdelim))
642 (let* ((error-pattern (make-regexp "^(Error|FAILED):.*"))
643 (checker (lambda (port)
644 (let loop ()
645 (let ((line (read-line port)))
646 (cond
647 ((eof-object? line) #t)
648 ((regexp-exec error-pattern line) #f)
649 (else (loop)))))))
650 (run-test (lambda (test)
651 (system* "make" test)
652 (call-with-input-file
653 (string-append "test/" test ".log")
654 checker))))
655 (or #t ; skip tests
656 (and (run-test "check-hotspot")
657 (run-test "check-langtools")
658 (run-test "check-jdk"))))))
659 (replace 'install
660 (lambda* (#:key outputs #:allow-other-keys)
661 (let ((doc (string-append (assoc-ref outputs "doc")
662 "/share/doc/icedtea"))
663 (jre (assoc-ref outputs "out"))
664 (jdk (assoc-ref outputs "jdk")))
665 (copy-recursively "openjdk.build/docs" doc)
666 (copy-recursively "openjdk.build/j2re-image" jre)
667 (copy-recursively "openjdk.build/j2sdk-image" jdk))))
668 ;; By default IcedTea only generates an empty keystore. In order to
669 ;; be able to use certificates in Java programs we need to generate a
670 ;; keystore from a set of certificates. For convenience we use the
671 ;; certificates from the nss-certs package.
672 (add-after 'install 'install-keystore
673 (lambda* (#:key inputs outputs #:allow-other-keys)
674 (let* ((keystore "cacerts")
675 (certs-dir (string-append (assoc-ref inputs "nss-certs")
676 "/etc/ssl/certs"))
677 (keytool (string-append (assoc-ref outputs "jdk")
678 "/bin/keytool")))
679 (define (extract-cert file target)
680 (call-with-input-file file
681 (lambda (in)
682 (call-with-output-file target
683 (lambda (out)
684 (let loop ((line (read-line in 'concat))
685 (copying? #f))
686 (cond
687 ((eof-object? line) #t)
688 ((string-prefix? "-----BEGIN" line)
689 (display line out)
690 (loop (read-line in 'concat) #t))
691 ((string-prefix? "-----END" line)
692 (display line out)
693 #t)
694 (else
695 (when copying? (display line out))
696 (loop (read-line in 'concat) copying?)))))))))
697 (define (import-cert cert)
698 (format #t "Importing certificate ~a\n" (basename cert))
699 (let ((temp "tmpcert"))
700 (extract-cert cert temp)
701 (let ((port (open-pipe* OPEN_WRITE keytool
702 "-import"
703 "-alias" (basename cert)
704 "-keystore" keystore
705 "-storepass" "changeit"
706 "-file" temp)))
707 (display "yes\n" port)
708 (when (not (zero? (status:exit-val (close-pipe port))))
709 (error "failed to import" cert)))
710 (delete-file temp)))
711
712 ;; This is necessary because the certificate directory contains
713 ;; files with non-ASCII characters in their names.
714 (setlocale LC_ALL "en_US.utf8")
715 (setenv "LC_ALL" "en_US.utf8")
716
717 (for-each import-cert (find-files certs-dir "\\.pem$"))
718 (mkdir-p (string-append (assoc-ref outputs "out")
719 "/lib/security"))
720 (mkdir-p (string-append (assoc-ref outputs "jdk")
721 "/jre/lib/security"))
722 (install-file keystore
723 (string-append (assoc-ref outputs "out")
724 "/lib/security"))
725 (install-file keystore
726 (string-append (assoc-ref outputs "jdk")
727 "/jre/lib/security"))
728 #t))))))
729 (native-inputs
730 `(("ant" ,ant)
731 ("alsa-lib" ,alsa-lib)
732 ("attr" ,attr)
733 ("autoconf" ,autoconf)
734 ("automake" ,automake)
735 ("coreutils" ,coreutils)
736 ("diffutils" ,diffutils) ;for tests
737 ("gawk" ,gawk)
738 ("grep" ,grep)
739 ("libtool" ,libtool)
740 ("pkg-config" ,pkg-config)
741 ("cups" ,cups)
742 ("wget" ,wget)
743 ("which" ,which)
744 ("cpio" ,cpio)
745 ("zip" ,zip)
746 ("unzip" ,unzip)
747 ("fastjar" ,fastjar)
748 ("libxslt" ,libxslt) ;for xsltproc
749 ("mit-krb5" ,mit-krb5)
750 ("nss" ,nss)
751 ("nss-certs" ,nss-certs)
752 ("libx11" ,libx11)
753 ("libxcomposite" ,libxcomposite)
754 ("libxt" ,libxt)
755 ("libxtst" ,libxtst)
756 ("libxi" ,libxi)
757 ("libxinerama" ,libxinerama)
758 ("libxrender" ,libxrender)
759 ("libjpeg" ,libjpeg)
760 ("libpng" ,libpng)
761 ("giflib" ,giflib)
762 ("perl" ,perl)
763 ("procps" ,procps) ;for "free", even though I'm not sure we should use it
764 ("openjdk6-src"
765 ,(origin
766 (method url-fetch)
767 (uri "https://java.net/downloads/openjdk6/openjdk-6-src-b40-22_aug_2016.tar.gz")
768 (sha256
769 (base32
770 "01v4q7g9pa6w7m6yxply5yrin08jgv12fck665xnmp09bpxy8sa5"))))
771 ("lcms" ,lcms)
772 ("zlib" ,zlib)
773 ("gtk" ,gtk+-2)
774 ("fontconfig" ,fontconfig)
775 ("freetype" ,freetype)
776 ("gcj" ,gcj)))
777 (home-page "http://icedtea.classpath.org")
778 (synopsis "Java development kit")
779 (description
780 "The OpenJDK built with the IcedTea build harness.")
781 ;; IcedTea is released under the GPL2 + Classpath exception, which is the
782 ;; same license as both GNU Classpath and OpenJDK.
783 (license license:gpl2+)))
784
785 (define-public icedtea-7
786 (let* ((version "2.6.7")
787 (drop (lambda (name hash)
788 (origin
789 (method url-fetch)
790 (uri (string-append
791 "http://icedtea.classpath.org/download/drops/"
792 "/icedtea7/" version "/" name ".tar.bz2"))
793 (sha256 (base32 hash))))))
794 (package (inherit icedtea-6)
795 (version version)
796 (source (origin
797 (method url-fetch)
798 (uri (string-append
799 "http://icedtea.wildebeest.org/download/source/icedtea-"
800 version ".tar.xz"))
801 (sha256
802 (base32
803 "1r4y1afjdm72j4lkd1jsim595zy5s3hvc3dnl13f5a7wrxp2v4nh"))
804 (modules '((guix build utils)))
805 (snippet
806 '(substitute* "Makefile.in"
807 ;; link against libgcj to avoid linker error
808 (("-o native-ecj")
809 "-lgcj -o native-ecj")
810 ;; do not leak information about the build host
811 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
812 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
813 (arguments
814 `(;; There are many test failures. Some are known to
815 ;; fail upstream, others relate to not having an X
816 ;; server running at test time, yet others are a
817 ;; complete mystery to me.
818
819 ;; hotspot: passed: 241; failed: 45; error: 2
820 ;; langtools: passed: 1,934; failed: 26
821 ;; jdk: unknown
822 #:tests? #f
823 ;; Apparently, the C locale is needed for some of the tests.
824 #:locale "C"
825 ,@(substitute-keyword-arguments (package-arguments icedtea-6)
826 ((#:modules modules)
827 `((ice-9 match)
828 (srfi srfi-26)
829 ,@modules))
830 ((#:configure-flags flags)
831 ;; TODO: package pcsc and sctp, and add to inputs
832 `(append '("--disable-system-pcsc"
833 "--disable-system-sctp")
834 ,flags))
835 ((#:phases phases)
836 `(modify-phases ,phases
837 (replace 'unpack
838 (lambda* (#:key source inputs #:allow-other-keys)
839 (let ((target (string-append "icedtea-" ,version))
840 (unpack (lambda* (name #:optional dir)
841 (let ((dir (or dir
842 (string-drop-right name 5))))
843 (mkdir dir)
844 (zero? (system* "tar" "xvf"
845 (assoc-ref inputs name)
846 "-C" dir
847 "--strip-components=1"))))))
848 (mkdir target)
849 (and
850 (zero? (system* "tar" "xvf" source
851 "-C" target "--strip-components=1"))
852 (chdir target)
853 (unpack "openjdk-src" "openjdk.src")
854 (with-directory-excursion "openjdk.src"
855 (for-each unpack
856 (filter (cut string-suffix? "-drop" <>)
857 (map (match-lambda
858 ((name . _) name))
859 inputs))))
860 #t))))
861 (replace
862 'set-additional-paths
863 (lambda* (#:key inputs #:allow-other-keys)
864 (let (;; Get target-specific include directory so that
865 ;; libgcj-config.h is found when compiling hotspot.
866 (gcjinclude (let* ((port (open-input-pipe "gcj -print-file-name=include"))
867 (str (read-line port)))
868 (close-pipe port)
869 str)))
870 (substitute* "openjdk.src/jdk/make/common/shared/Sanity.gmk"
871 (("ALSA_INCLUDE=/usr/include/alsa/version.h")
872 (string-append "ALSA_INCLUDE="
873 (assoc-ref inputs "alsa-lib")
874 "/include/alsa/version.h")))
875 (setenv "CC" "gcc")
876 (setenv "CPATH"
877 (string-append gcjinclude ":"
878 (assoc-ref inputs "libxcomposite")
879 "/include/X11/extensions" ":"
880 (assoc-ref inputs "libxrender")
881 "/include/X11/extensions" ":"
882 (assoc-ref inputs "libxtst")
883 "/include/X11/extensions" ":"
884 (assoc-ref inputs "libxinerama")
885 "/include/X11/extensions" ":"
886 (or (getenv "CPATH") "")))
887 (setenv "ALT_OBJCOPY" (which "objcopy"))
888 (setenv "ALT_CUPS_HEADERS_PATH"
889 (string-append (assoc-ref inputs "cups")
890 "/include"))
891 (setenv "ALT_FREETYPE_HEADERS_PATH"
892 (string-append (assoc-ref inputs "freetype")
893 "/include"))
894 (setenv "ALT_FREETYPE_LIB_PATH"
895 (string-append (assoc-ref inputs "freetype")
896 "/lib")))))
897 (add-after
898 'unpack 'fix-x11-extension-include-path
899 (lambda* (#:key inputs #:allow-other-keys)
900 (substitute* "openjdk.src/jdk/make/sun/awt/mawt.gmk"
901 (((string-append "\\$\\(firstword \\$\\(wildcard "
902 "\\$\\(OPENWIN_HOME\\)"
903 "/include/X11/extensions\\).*$"))
904 (string-append (assoc-ref inputs "libxrender")
905 "/include/X11/extensions"
906 " -I" (assoc-ref inputs "libxtst")
907 "/include/X11/extensions"
908 " -I" (assoc-ref inputs "libxinerama")
909 "/include/X11/extensions"))
910 (("\\$\\(wildcard /usr/include/X11/extensions\\)\\)") ""))
911 #t))
912 (replace
913 'fix-test-framework
914 (lambda _
915 ;; Fix PATH in test environment
916 (substitute* "test/jtreg/com/sun/javatest/regtest/Main.java"
917 (("PATH=/bin:/usr/bin")
918 (string-append "PATH=" (getenv "PATH"))))
919 (substitute* "test/jtreg/com/sun/javatest/util/SysEnv.java"
920 (("/usr/bin/env") (which "env")))
921 (substitute* "openjdk.src/hotspot/test/test_env.sh"
922 (("/bin/rm") (which "rm"))
923 (("/bin/cp") (which "cp"))
924 (("/bin/mv") (which "mv")))
925 #t))
926 (delete 'patch-patches))))))
927 (native-inputs
928 `(("openjdk-src"
929 ,(drop "openjdk"
930 "0y38vgvzw2xggfg0nlalv42amy5sv6vzvjxik8bvkm1sajzazb2w"))
931 ("corba-drop"
932 ,(drop "corba"
933 "0r778nhmzcnf6jkl50f6f279vbzh96rcwr74vb0930wgl2g46j80"))
934 ("jaxp-drop"
935 ,(drop "jaxp"
936 "02y7zaw4irjvbihpr4pbrl64pxjx5anfxms3i24rp1q6aj2n1gcz"))
937 ("jaxws-drop"
938 ,(drop "jaxws"
939 "1xrhdgykpi7amyyirzchp4mjrx2j3xm6nqg4bbfy2kxv7daw3z69"))
940 ("jdk-drop"
941 ,(drop "jdk"
942 "108d560iabk334lcifr5xf1w075a6c918smpbcaccsrln8qd6g79"))
943 ("langtools-drop"
944 ,(drop "langtools"
945 "1r5llvhxzdihyz6rmr6ri9wz8zvbw4gmlllhb340p86liqqh1rqk"))
946 ("hotspot-drop"
947 ,(drop "hotspot"
948 "0p3arg01jfdnbx856qfhhzp7s9yzmqwa1fspk5spmmxb9m7mj4h4"))
949 ,@(fold alist-delete (package-native-inputs icedtea-6)
950 '("openjdk6-src"))))
951 (inputs
952 `(("libxcomposite" ,libxcomposite)
953 ,@(package-inputs icedtea-6))))))
954
955 (define-public icedtea-8
956 (let* ((version "3.1.0")
957 (drop (lambda (name hash)
958 (origin
959 (method url-fetch)
960 (uri (string-append
961 "http://icedtea.classpath.org/download/drops/"
962 "/icedtea8/" version "/" name ".tar.xz"))
963 (sha256 (base32 hash))))))
964 (package (inherit icedtea-7)
965 (version "3.1.0")
966 (source (origin
967 (method url-fetch)
968 (uri (string-append
969 "http://icedtea.wildebeest.org/download/source/icedtea-"
970 version ".tar.xz"))
971 (sha256
972 (base32
973 "1d1kj8a6jbvcbzhmfrx2pca7pinsvpxd7zij9h93g13dmm0ncqbm"))
974 (modules '((guix build utils)))
975 (snippet
976 '(substitute* "Makefile.am"
977 ;; do not leak information about the build host
978 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
979 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
980 (arguments
981 (substitute-keyword-arguments (package-arguments icedtea-7)
982 ((#:configure-flags flags)
983 `(let ((jdk (assoc-ref %build-inputs "jdk")))
984 `(;;"--disable-bootstrap"
985 "--enable-bootstrap"
986 "--enable-nss"
987 "--disable-downloading"
988 "--disable-tests" ;they are run in the check phase instead
989 "--with-openjdk-src-dir=./openjdk.src"
990 ,(string-append "--with-jdk-home=" jdk))))
991 ((#:phases phases)
992 `(modify-phases ,phases
993 (delete 'fix-x11-extension-include-path)
994 (delete 'patch-paths)
995 (delete 'set-additional-paths)
996 (delete 'patch-patches)
997 ;; FIXME: This phase is needed but fails with this version of
998 ;; IcedTea.
999 (delete 'install-keystore)
1000 (replace 'install
1001 (lambda* (#:key outputs #:allow-other-keys)
1002 (let ((doc (string-append (assoc-ref outputs "doc")
1003 "/share/doc/icedtea"))
1004 (jre (assoc-ref outputs "out"))
1005 (jdk (assoc-ref outputs "jdk")))
1006 (copy-recursively "openjdk.build/docs" doc)
1007 (copy-recursively "openjdk.build/images/j2re-image" jre)
1008 (copy-recursively "openjdk.build/images/j2sdk-image" jdk)
1009 #t)))))))
1010 (native-inputs
1011 `(("jdk" ,icedtea-7 "jdk")
1012 ("openjdk-src"
1013 ,(drop "openjdk"
1014 "1p6xgf00w754y3xdrccs67gjhb0181q49dk67h5v43aixkx7z7y1"))
1015 ("corba-drop"
1016 ,(drop "corba"
1017 "088wnyfdhqkvc41pl3swnynbxx7x5lha6qg7q0biai6ya114scsy"))
1018 ("jaxp-drop"
1019 ,(drop "jaxp"
1020 "18xc4sib85z2zhz4k5lvi5b4vn88zqjpa3wi8gav81vz5gyysn3d"))
1021 ("jaxws-drop"
1022 ,(drop "jaxws"
1023 "1my72q2zjly4imn834zgf4rysn48gbr8i81rxzrfdqgzzinxf6l1"))
1024 ("jdk-drop"
1025 ,(drop "jdk"
1026 "1ab2h7pppph82h3xhh1m5dha77j3wnhksq7c7f8yfcsyhr5hm243"))
1027 ("langtools-drop"
1028 ,(drop "langtools"
1029 "07bzcw2ml4apjfd0ydc3v44fnnwinwri114fig2mdcn1n388szra"))
1030 ("hotspot-drop"
1031 ,(drop "hotspot"
1032 "0x5ic8cz3w9s8m8ynh31qlf47c6nwc512bp8ddwgmvsdxyiiwn1k"))
1033 ("nashorn-drop"
1034 ,(drop "nashorn"
1035 "0zyd8pyv1il8c9npw7wz1mwxhlq510ill20nhc7i8fq7gignzcsn"))
1036 ("shenandoah-drop"
1037 ,(drop "shenandoah"
1038 "1shisljn60zw9j4nahh07vw85gj25gfiy7z196fdw0pi95va6qwk"))
1039 ,@(fold alist-delete (package-native-inputs icedtea-7)
1040 '("gcj" "openjdk-src" "corba-drop" "jaxp-drop" "jaxws-drop"
1041 "jdk-drop" "langtools-drop" "hotspot-drop")))))))
1042
1043 (define-public icedtea icedtea-7)
1044
1045 (define-public java-xz
1046 (package
1047 (name "java-xz")
1048 (version "1.5")
1049 (source (origin
1050 (method url-fetch)
1051 (uri (string-append "http://tukaani.org/xz/xz-java-" version ".zip"))
1052 (sha256
1053 (base32
1054 "0x6vn9dp9kxk83x2fp3394n95dk8fx9yg8jns9371iqsn0vy8ih1"))))
1055 (build-system ant-build-system)
1056 (arguments
1057 `(#:tests? #f ; There are no tests to run.
1058 #:jar-name ,(string-append "xz-" version ".jar")
1059 #:phases
1060 (modify-phases %standard-phases
1061 ;; The unpack phase enters the "maven" directory by accident.
1062 (add-after 'unpack 'chdir
1063 (lambda _ (chdir "..") #t)))))
1064 (native-inputs
1065 `(("unzip" ,unzip)))
1066 (home-page "http://tukaani.org/xz/java.html")
1067 (synopsis "Implementation of XZ data compression in pure Java")
1068 (description "This library aims to be a complete implementation of XZ data
1069 compression in pure Java. Single-threaded streamed compression and
1070 decompression and random access decompression have been fully implemented.")
1071 (license license:public-domain)))
1072
1073 ;; java-hamcrest-core uses qdox version 1.12. We package this version instead
1074 ;; of the latest release.
1075 (define-public java-qdox-1.12
1076 (package
1077 (name "java-qdox")
1078 (version "1.12.1")
1079 (source (origin
1080 (method url-fetch)
1081 (uri (string-append "http://central.maven.org/maven2/"
1082 "com/thoughtworks/qdox/qdox/" version
1083 "/qdox-" version "-sources.jar"))
1084 (sha256
1085 (base32
1086 "0hlfbqq2avf5s26wxkksqmkdyk6zp9ggqn37c468m96mjv0n9xfl"))))
1087 (build-system ant-build-system)
1088 (arguments
1089 `(;; Tests require junit
1090 #:tests? #f
1091 #:jar-name "qdox.jar"
1092 #:phases
1093 (modify-phases %standard-phases
1094 (replace 'unpack
1095 (lambda* (#:key source #:allow-other-keys)
1096 (mkdir "src")
1097 (with-directory-excursion "src"
1098 (zero? (system* "jar" "-xf" source)))))
1099 ;; At this point we don't have junit, so we must remove the API
1100 ;; tests.
1101 (add-after 'unpack 'delete-tests
1102 (lambda _
1103 (delete-file-recursively "src/com/thoughtworks/qdox/junit")
1104 #t)))))
1105 (home-page "http://qdox.codehaus.org/")
1106 (synopsis "Parse definitions from Java source files")
1107 (description
1108 "QDox is a high speed, small footprint parser for extracting
1109 class/interface/method definitions from source files complete with JavaDoc
1110 @code{@@tags}. It is designed to be used by active code generators or
1111 documentation tools.")
1112 (license license:asl2.0)))
1113
1114 (define-public java-jarjar
1115 (package
1116 (name "java-jarjar")
1117 (version "1.4")
1118 (source (origin
1119 (method url-fetch)
1120 (uri (string-append
1121 "https://storage.googleapis.com/google-code-archive-downloads/v2/"
1122 "code.google.com/jarjar/jarjar-src-" version ".zip"))
1123 (sha256
1124 (base32
1125 "1v8irhni9cndcw1l1wxqgry013s2kpj0qqn57lj2ji28xjq8ndjl"))))
1126 (build-system ant-build-system)
1127 (arguments
1128 `(;; Tests require junit, which ultimately depends on this package.
1129 #:tests? #f
1130 #:build-target "jar"
1131 #:phases
1132 (modify-phases %standard-phases
1133 (replace 'install
1134 (lambda* (#:key outputs #:allow-other-keys)
1135 (let ((target (string-append (assoc-ref outputs "out")
1136 "/share/java")))
1137 (install-file (string-append "dist/jarjar-" ,version ".jar")
1138 target))
1139 #t)))))
1140 (native-inputs
1141 `(("unzip" ,unzip)))
1142 (home-page "https://code.google.com/archive/p/jarjar/")
1143 (synopsis "Repackage Java libraries")
1144 (description
1145 "Jar Jar Links is a utility that makes it easy to repackage Java
1146 libraries and embed them into your own distribution. Jar Jar Links includes
1147 an Ant task that extends the built-in @code{jar} task.")
1148 (license license:asl2.0)))
1149
1150 (define-public java-hamcrest-core
1151 (package
1152 (name "java-hamcrest-core")
1153 (version "1.3")
1154 (source (origin
1155 (method url-fetch)
1156 (uri (string-append "https://hamcrest.googlecode.com/files/"
1157 "hamcrest-" version ".tgz"))
1158 (sha256
1159 (base32
1160 "1hi0jv0zrgsf4l25aizxrgvxpsrmdklsmvw0jzwz7zv9s108whn6"))
1161 (modules '((guix build utils)))
1162 (snippet
1163 '(begin
1164 ;; Delete bundled jar archives.
1165 (for-each delete-file (find-files "." "\\.jar$"))
1166 #t))))
1167 (build-system ant-build-system)
1168 (arguments
1169 `(#:tests? #f ; Tests require junit
1170 #:make-flags (list (string-append "-Dversion=" ,version))
1171 #:build-target "core"
1172 #:phases
1173 (modify-phases %standard-phases
1174 ;; Disable unit tests, because they require junit, which requires
1175 ;; hamcrest-core. We also give a fixed value to the "Built-Date"
1176 ;; attribute from the manifest for reproducibility.
1177 (add-before 'configure 'patch-build.xml
1178 (lambda _
1179 (substitute* "build.xml"
1180 (("unit-test, ") "")
1181 (("\\$\\{build.timestamp\\}") "guix"))
1182 #t))
1183 ;; Java's "getMethods()" returns methods in an unpredictable order.
1184 ;; To make the output of the generated code deterministic we must
1185 ;; sort the array of methods.
1186 (add-after 'unpack 'make-method-order-deterministic
1187 (lambda _
1188 (substitute* "hamcrest-generator/src/main/java/org/hamcrest/generator/ReflectiveFactoryReader.java"
1189 (("import java\\.util\\.Iterator;" line)
1190 (string-append line "\n"
1191 "import java.util.Arrays; import java.util.Comparator;"))
1192 (("allMethods = cls\\.getMethods\\(\\);" line)
1193 (string-append "_" line
1194 "
1195 private Method[] getSortedMethods() {
1196 Arrays.sort(_allMethods, new Comparator<Method>() {
1197 @Override
1198 public int compare(Method a, Method b) {
1199 return a.toString().compareTo(b.toString());
1200 }
1201 });
1202 return _allMethods;
1203 }
1204
1205 private Method[] allMethods = getSortedMethods();")))))
1206 (add-before 'build 'do-not-use-bundled-qdox
1207 (lambda* (#:key inputs #:allow-other-keys)
1208 (substitute* "build.xml"
1209 (("lib/generator/qdox-1.12.jar")
1210 (string-append (assoc-ref inputs "java-qdox-1.12")
1211 "/share/java/qdox.jar")))
1212 #t))
1213 (replace 'install
1214 (lambda* (#:key outputs #:allow-other-keys)
1215 (install-file (string-append "build/hamcrest-core-"
1216 ,version ".jar")
1217 (string-append (assoc-ref outputs "out")
1218 "/share/java")))))))
1219 (native-inputs
1220 `(("java-qdox-1.12" ,java-qdox-1.12)
1221 ("java-jarjar" ,java-jarjar)))
1222 (home-page "http://hamcrest.org/")
1223 (synopsis "Library of matchers for building test expressions")
1224 (description
1225 "This package provides a library of matcher objects (also known as
1226 constraints or predicates) allowing @code{match} rules to be defined
1227 declaratively, to be used in other frameworks. Typical scenarios include
1228 testing frameworks, mocking libraries and UI validation rules.")
1229 (license license:bsd-2)))
1230
1231 (define-public java-junit
1232 (package
1233 (name "java-junit")
1234 (version "4.12")
1235 (source (origin
1236 (method url-fetch)
1237 (uri (string-append "https://github.com/junit-team/junit/"
1238 "archive/r" version ".tar.gz"))
1239 (file-name (string-append name "-" version ".tar.gz"))
1240 (sha256
1241 (base32
1242 "090dn5v1vs0b3acyaqc0gjf6p8lmd2h24wfzsbq7sly6b214anws"))
1243 (modules '((guix build utils)))
1244 (snippet
1245 '(begin
1246 ;; Delete bundled jar archives.
1247 (delete-file-recursively "lib")
1248 #t))))
1249 (build-system ant-build-system)
1250 (arguments
1251 `(#:tests? #f ; no tests
1252 #:jar-name "junit.jar"))
1253 (inputs
1254 `(("java-hamcrest-core" ,java-hamcrest-core)))
1255 (home-page "http://junit.org/")
1256 (synopsis "Test framework for Java")
1257 (description
1258 "JUnit is a simple framework to write repeatable tests for Java projects.
1259 JUnit provides assertions for testing expected results, test fixtures for
1260 sharing common test data, and test runners for running tests.")
1261 (license license:epl1.0)))