1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
4 ;;; Copyright © 2016, 2017 Roel Janssen <roel@gnu.org>
5 ;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages java)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix utils)
27 #:use-module (guix build-system ant)
28 #:use-module (guix build-system gnu)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages attr)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages bash)
34 #:use-module (gnu packages certs)
35 #:use-module (gnu packages cpio)
36 #:use-module (gnu packages cups)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages fontutils)
39 #:use-module (gnu packages gawk)
40 #:use-module (gnu packages gcc)
41 #:use-module (gnu packages gl)
42 #:use-module (gnu packages gnuzilla) ;nss
43 #:use-module (gnu packages ghostscript) ;lcms
44 #:use-module (gnu packages gnome)
45 #:use-module (gnu packages gtk)
46 #:use-module (gnu packages image)
47 #:use-module (gnu packages linux) ;alsa
48 #:use-module (gnu packages wget)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages perl)
51 #:use-module (gnu packages kerberos)
52 #:use-module (gnu packages xml)
53 #:use-module (gnu packages xorg)
54 #:use-module (gnu packages zip)
55 #:use-module (gnu packages texinfo)
56 #:use-module ((srfi srfi-1) #:select (fold alist-delete))
57 #:use-module (srfi srfi-11)
58 #:use-module (ice-9 match))
60 (define-public java-swt
65 ;; The types of many variables and procedures differ in the sources
66 ;; dependent on whether the target architecture is a 32-bit system or a
67 ;; 64-bit system. Instead of patching the sources on demand in a build
68 ;; phase we download either the 32-bit archive (which mostly uses "int"
69 ;; types) or the 64-bit archive (which mostly uses "long" types).
70 (let ((hash32 "0jmx1h65wqxsyjzs64i2z6ryiynllxzm13cq90fky2qrzagcw1ir")
71 (hash64 "0wnd01xssdq9pgx5xqh5lfiy3dmk60dzzqdxzdzf883h13692lgy")
74 (let-values (((hash file)
75 (match (or (%current-target-system) (%current-system))
76 ("x86_64-linux" (values hash64 file64))
77 (_ (values hash32 file32)))))
81 "http://ftp-stud.fht-esslingen.de/pub/Mirrors/"
82 "eclipse/eclipse/downloads/drops4/R-" version
83 "-201606061100/swt-" version "-gtk-linux-" file ".zip"))
84 (sha256 (base32 hash))))))
85 (build-system ant-build-system)
87 `(#:jar-name "swt.jar"
88 #:tests? #f ; no "check" target
90 (modify-phases %standard-phases
92 (lambda* (#:key source #:allow-other-keys)
94 (zero? (system* "unzip" source "-d" "swt"))
97 (zero? (system* "unzip" "src.zip" "-d" "src")))))
98 ;; The classpath contains invalid icecat jars. Since we don't need
99 ;; anything other than the JDK on the classpath, we can simply unset
101 (add-after 'configure 'unset-classpath
102 (lambda _ (unsetenv "CLASSPATH") #t))
103 (add-before 'build 'build-native
104 (lambda* (#:key inputs outputs #:allow-other-keys)
105 (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
106 ;; Build shared libraries. Users of SWT have to set the system
107 ;; property swt.library.path to the "lib" directory of this
110 (setenv "OUTPUT_DIR" lib)
111 (with-directory-excursion "src"
112 (zero? (system* "bash" "build.sh"))))))
113 (add-after 'install 'install-native
114 (lambda* (#:key outputs #:allow-other-keys)
115 (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
116 (for-each (lambda (file)
117 (install-file file lib))
118 (find-files "." "\\.so$"))
121 `(("xulrunner" ,icecat)
128 `(("pkg-config" ,pkg-config)
130 (home-page "https://www.eclipse.org/swt/")
131 (synopsis "Widget toolkit for Java")
133 "SWT is a widget toolkit for Java designed to provide efficient, portable
134 access to the user-interface facilities of the operating systems on which it
136 ;; SWT code is licensed under EPL1.0
137 ;; Gnome and Gtk+ bindings contain code licensed under LGPLv2.1
138 ;; Cairo bindings contain code under MPL1.1
139 ;; XULRunner 1.9 bindings contain code under MPL2.0
146 (define-public clojure
147 (let* ((remove-archives '(begin
148 (for-each delete-file
149 (find-files "." ".*\\.(jar|zip)"))
151 (submodule (lambda (prefix version hash)
154 (uri (string-append "https://github.com/clojure/"
155 prefix version ".tar.gz"))
156 (sha256 (base32 hash))
157 (modules '((guix build utils)))
158 (snippet remove-archives)))))
166 (string-append "http://repo1.maven.org/maven2/org/clojure/clojure/"
167 version "/clojure-" version ".zip"))
169 (base32 "1nip095fz5c492sw15skril60i1vd21ibg6szin4jcvyy3xr6cym"))
170 (modules '((guix build utils)))
171 (snippet remove-archives)))
172 (build-system ant-build-system)
174 `(#:modules ((guix build ant-build-system)
182 (modify-phases %standard-phases
183 (add-after 'unpack 'unpack-submodule-sources
184 (lambda* (#:key inputs #:allow-other-keys)
188 (with-directory-excursion name
189 (or (zero? (system* "tar"
190 ;; Use xz for repacked tarball.
194 "--file" (assoc-ref inputs name)
195 "--strip-components=1"))
196 (error "failed to unpack tarball" name)))
197 (copy-recursively (string-append name "/src/main/clojure/")
199 '("data-generators-src"
202 "test-generative-src"
203 "tools-namespace-src"
206 ;; The javadoc target is not built by default.
207 (add-after 'build 'build-doc
209 (zero? (system* "ant" "javadoc"))))
210 ;; Needed since no install target is provided.
212 (lambda* (#:key outputs #:allow-other-keys)
213 (let ((java-dir (string-append (assoc-ref outputs "out")
215 ;; Install versioned to avoid collisions.
216 (install-file (string-append "clojure-" ,version ".jar")
219 ;; Needed since no install-doc target is provided.
220 (add-after 'install 'install-doc
221 (lambda* (#:key outputs #:allow-other-keys)
222 (let ((doc-dir (string-append (assoc-ref outputs "out")
223 "/share/doc/clojure-"
225 (copy-recursively "doc/clojure" doc-dir)
226 (copy-recursively "target/javadoc/"
227 (string-append doc-dir "javadoc/"))
228 (for-each (cut install-file <> doc-dir)
229 (filter (cut string-match
230 ".*\\.(html|markdown|md|txt)"
234 ;; The native-inputs below are needed to run the tests.
236 `(("data-generators-src"
237 ,(submodule "data.generators/archive/data.generators-"
239 "0kki093jp4ckwxzfnw8ylflrfqs8b1i1wi9iapmwcsy328dmgzp1"))
240 ("java-classpath-src"
241 ,(submodule "java.classpath/archive/java.classpath-"
243 "0sjymly9xh1lkvwn5ygygpsfwz4dabblnlq0c9bx76rkvq62fyng"))
245 ,(submodule "test.check/archive/test.check-"
247 "0p0mnyhr442bzkz0s4k5ra3i6l5lc7kp6ajaqkkyh4c2k5yck1md"))
248 ("test-generative-src"
249 ,(submodule "test.generative/archive/test.generative-"
251 "1pjafy1i7yblc7ixmcpfq1lfbyf3jaljvkgrajn70sws9xs7a9f8"))
252 ("tools-namespace-src"
253 ,(submodule "tools.namespace/archive/tools.namespace-"
255 "10baak8v0hnwz2hr33bavshm7y49mmn9zsyyms1dwjz45p5ymhy0"))
257 ,(submodule "tools.reader/archive/tools.reader-"
259 "09i3lzbhr608h76mhdjm3932gg9xi8sflscla3c5f0v1nkc28cnr"))))
260 (home-page "https://clojure.org/")
261 (synopsis "Lisp dialect running on the JVM")
262 (description "Clojure is a dynamic, general-purpose programming language,
263 combining the approachability and interactive development of a scripting
264 language with an efficient and robust infrastructure for multithreaded
265 programming. Clojure is a compiled language, yet remains completely dynamic
266 – every feature supported by Clojure is supported at runtime. Clojure
267 provides easy access to the Java frameworks, with optional type hints and type
268 inference, to ensure that calls to Java can avoid reflection.
270 Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy
271 and a powerful macro system. Clojure is predominantly a functional programming
272 language, and features a rich set of immutable, persistent data structures.
273 When mutable state is needed, Clojure offers a software transactional memory
274 system and reactive Agent system that ensure clean, correct, multithreaded
276 ;; Clojure is licensed under EPL1.0
277 ;; ASM bytecode manipulation library is licensed under BSD-3
278 ;; Guava Murmur3 hash implementation is licensed under APL2.0
279 ;; src/clj/repl.clj is licensed under CPL1.0
281 ;; See readme.html or readme.txt for details.
282 (license (list license:epl1.0
293 (uri (string-append "mirror://apache/ant/source/apache-ant-"
294 version "-src.tar.gz"))
297 "1396wflczyxjxl603dhxjvd559f289lha9y2f04f71c7hapjl3am"))))
298 (build-system gnu-build-system)
300 `(#:tests? #f ; no "check" target
303 'unpack 'remove-scripts
304 ;; Remove bat / cmd scripts for DOS as well as the antRun and runant
307 (for-each delete-file
308 (find-files "src/script"
309 "(.*\\.(bat|cmd)|runant.*|antRun.*)")))
313 (setenv "JAVA_HOME" (string-append (assoc-ref %build-inputs "gcj")
315 ;; Disable tests to avoid dependency on hamcrest-core, which needs
316 ;; Ant to build. This is necessary in addition to disabling the
317 ;; "check" phase, because the dependency on "test-jar" would always
318 ;; result in the tests to be run.
319 (substitute* "build.xml"
320 (("depends=\"jars,test-jar\"") "depends=\"jars\""))
321 (zero? (system* "bash" "bootstrap.sh"
322 (string-append "-Ddist.dir="
323 (assoc-ref %outputs "out")))))
326 (alist-delete 'install %standard-phases))))))
329 (home-page "http://ant.apache.org")
330 (synopsis "Build tool for Java")
332 "Ant is a platform-independent build tool for Java. It is similar to
333 make but is implemented using the Java language, requires the Java platform,
334 and is best suited to building Java projects. Ant uses XML to describe the
335 build process and its dependencies, whereas Make uses Makefile format.")
336 (license license:asl2.0)))
338 (define-public icedtea-7
339 (let* ((version "2.6.9")
340 (drop (lambda (name hash)
344 "http://icedtea.classpath.org/download/drops/"
345 "/icedtea7/" version "/" name ".tar.bz2"))
346 (sha256 (base32 hash))))))
353 "http://icedtea.wildebeest.org/download/source/icedtea-"
357 "1slmajiakq7sk137vgqq9c93r5s620a46lw2jwbnzxhysjw3wkwf"))
358 (modules '((guix build utils)))
360 '(substitute* "Makefile.in"
361 ;; link against libgcj to avoid linker error
363 "-lgcj -o native-ecj")
364 ;; do not leak information about the build host
365 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
366 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
367 (build-system gnu-build-system)
368 (outputs '("out" ; Java Runtime Environment
369 "jdk" ; Java Development Kit
370 "doc")) ; all documentation
372 `(;; There are many test failures. Some are known to
373 ;; fail upstream, others relate to not having an X
374 ;; server running at test time, yet others are a
375 ;; complete mystery to me.
377 ;; hotspot: passed: 241; failed: 45; error: 2
378 ;; langtools: passed: 1,934; failed: 26
382 ;; The DSOs use $ORIGIN to refer to each other, but (guix build
383 ;; gremlin) doesn't support it yet, so skip this phase.
384 #:validate-runpath? #f
386 ;; Apparently, the C locale is needed for some of the tests.
389 #:modules ((guix build utils)
390 (guix build gnu-build-system)
398 (let* ((gcjdir (assoc-ref %build-inputs "gcj"))
399 (ecj (string-append gcjdir "/share/java/ecj.jar"))
400 (jdk (string-append gcjdir "/lib/jvm/"))
401 (gcj (string-append gcjdir "/bin/gcj")))
402 ;; TODO: package pcsc and sctp, and add to inputs
403 `("--disable-system-pcsc"
404 "--disable-system-sctp"
408 "--disable-downloading"
409 "--disable-tests" ;they are run in the check phase instead
410 "--with-openjdk-src-dir=./openjdk.src"
411 ,(string-append "--with-javac=" jdk "/bin/javac")
412 ,(string-append "--with-ecj-jar=" ecj)
413 ,(string-append "--with-gcj=" gcj)
414 ,(string-append "--with-jdk-home=" jdk)
415 ,(string-append "--with-java=" jdk "/bin/java")))
418 (modify-phases %standard-phases
420 (lambda* (#:key source inputs #:allow-other-keys)
421 (let ((target (string-append "icedtea-" ,version))
422 (unpack (lambda* (name #:optional dir)
424 (string-drop-right name 5))))
426 (zero? (system* "tar" "xvf"
427 (assoc-ref inputs name)
429 "--strip-components=1"))))))
432 (zero? (system* "tar" "xvf" source
433 "-C" target "--strip-components=1"))
435 (unpack "openjdk-src" "openjdk.src")
436 (with-directory-excursion "openjdk.src"
438 (filter (cut string-suffix? "-drop" <>)
443 (add-after 'unpack 'fix-x11-extension-include-path
444 (lambda* (#:key inputs #:allow-other-keys)
445 (substitute* "openjdk.src/jdk/make/sun/awt/mawt.gmk"
446 (((string-append "\\$\\(firstword \\$\\(wildcard "
447 "\\$\\(OPENWIN_HOME\\)"
448 "/include/X11/extensions\\).*$"))
449 (string-append (assoc-ref inputs "libxrender")
450 "/include/X11/extensions"
451 " -I" (assoc-ref inputs "libxtst")
452 "/include/X11/extensions"
453 " -I" (assoc-ref inputs "libxinerama")
454 "/include/X11/extensions"))
455 (("\\$\\(wildcard /usr/include/X11/extensions\\)\\)") ""))
457 (add-after 'unpack 'patch-paths
459 ;; buildtree.make generates shell scripts, so we need to replace
460 ;; the generated shebang
461 (substitute* '("openjdk.src/hotspot/make/linux/makefiles/buildtree.make")
462 (("/bin/sh") (which "bash")))
464 (let ((corebin (string-append
465 (assoc-ref %build-inputs "coreutils") "/bin/"))
466 (binbin (string-append
467 (assoc-ref %build-inputs "binutils") "/bin/"))
468 (grepbin (string-append
469 (assoc-ref %build-inputs "grep") "/bin/")))
470 (substitute* '("openjdk.src/jdk/make/common/shared/Defs-linux.gmk"
471 "openjdk.src/corba/make/common/shared/Defs-linux.gmk")
472 (("UNIXCOMMAND_PATH = /bin/")
473 (string-append "UNIXCOMMAND_PATH = " corebin))
474 (("USRBIN_PATH = /usr/bin/")
475 (string-append "USRBIN_PATH = " corebin))
476 (("DEVTOOLS_PATH *= */usr/bin/")
477 (string-append "DEVTOOLS_PATH = " corebin))
478 (("COMPILER_PATH *= */usr/bin/")
479 (string-append "COMPILER_PATH = "
480 (assoc-ref %build-inputs "gcc") "/bin/"))
481 (("DEF_OBJCOPY *=.*objcopy")
482 (string-append "DEF_OBJCOPY = " (which "objcopy"))))
484 ;; fix path to alsa header
485 (substitute* "openjdk.src/jdk/make/common/shared/Sanity.gmk"
486 (("ALSA_INCLUDE=/usr/include/alsa/version.h")
487 (string-append "ALSA_INCLUDE="
488 (assoc-ref %build-inputs "alsa-lib")
489 "/include/alsa/version.h")))
491 ;; fix hard-coded utility paths
492 (substitute* '("openjdk.src/jdk/make/common/shared/Defs-utils.gmk"
493 "openjdk.src/corba/make/common/shared/Defs-utils.gmk")
495 (string-append "ECHO = " (which "echo")))
497 (string-append "GREP = " (which "grep")))
499 (string-append "EGREP = " (which "egrep")))
501 (string-append "CPIO = " (which "cpio")))
502 (("READELF *=.*readelf")
503 (string-append "READELF = " (which "readelf")))
505 (string-append "AR = " (which "ar")))
507 (string-append "TAR = " (which "tar")))
509 (string-append "AS = " (which "as")))
511 (string-append "LD = " (which "ld")))
513 (string-append "STRIP = " (which "strip")))
515 (string-append "NM = " (which "nm")))
517 (string-append "SH = " (which "bash")))
519 (string-append "FIND = " (which "find")))
521 (string-append "LDD = " (which "ldd")))
522 (("NAWK *=.*(n|g)awk")
523 (string-append "NAWK = " (which "gawk")))
525 (string-append "XARGS = " (which "xargs")))
527 (string-append "UNZIP = " (which "unzip")))
529 (string-append "ZIPEXE = " (which "zip")))
531 (string-append "SED = " (which "sed"))))
533 ;; Some of these timestamps cause problems as they are more than
534 ;; 10 years ago, failing the build process.
536 "openjdk.src/jdk/src/share/classes/java/util/CurrencyData.properties"
537 (("AZ=AZM;2005-12-31-20-00-00;AZN") "AZ=AZN")
538 (("MZ=MZM;2006-06-30-22-00-00;MZN") "MZ=MZN")
539 (("RO=ROL;2005-06-30-21-00-00;RON") "RO=RON")
540 (("TR=TRL;2004-12-31-22-00-00;TRY") "TR=TRY")))
542 (add-before 'configure 'set-additional-paths
543 (lambda* (#:key inputs #:allow-other-keys)
544 (let ( ;; Get target-specific include directory so that
545 ;; libgcj-config.h is found when compiling hotspot.
546 (gcjinclude (let* ((port (open-input-pipe "gcj -print-file-name=include"))
547 (str (read-line port)))
550 (substitute* "openjdk.src/jdk/make/common/shared/Sanity.gmk"
551 (("ALSA_INCLUDE=/usr/include/alsa/version.h")
552 (string-append "ALSA_INCLUDE="
553 (assoc-ref inputs "alsa-lib")
554 "/include/alsa/version.h")))
557 (string-append gcjinclude ":"
558 (assoc-ref inputs "libxcomposite")
559 "/include/X11/extensions" ":"
560 (assoc-ref inputs "libxrender")
561 "/include/X11/extensions" ":"
562 (assoc-ref inputs "libxtst")
563 "/include/X11/extensions" ":"
564 (assoc-ref inputs "libxinerama")
565 "/include/X11/extensions" ":"
566 (or (getenv "CPATH") "")))
567 (setenv "ALT_OBJCOPY" (which "objcopy"))
568 (setenv "ALT_CUPS_HEADERS_PATH"
569 (string-append (assoc-ref inputs "cups")
571 (setenv "ALT_FREETYPE_HEADERS_PATH"
572 (string-append (assoc-ref inputs "freetype")
574 (setenv "ALT_FREETYPE_LIB_PATH"
575 (string-append (assoc-ref inputs "freetype")
578 (add-before 'check 'fix-test-framework
580 ;; Fix PATH in test environment
581 (substitute* "test/jtreg/com/sun/javatest/regtest/Main.java"
582 (("PATH=/bin:/usr/bin")
583 (string-append "PATH=" (getenv "PATH"))))
584 (substitute* "test/jtreg/com/sun/javatest/util/SysEnv.java"
585 (("/usr/bin/env") (which "env")))
586 (substitute* "openjdk.src/hotspot/test/test_env.sh"
587 (("/bin/rm") (which "rm"))
588 (("/bin/cp") (which "cp"))
589 (("/bin/mv") (which "mv")))
591 (add-before 'check 'fix-hotspot-tests
593 (with-directory-excursion "openjdk.src/hotspot/test/"
594 (substitute* "jprt.config"
595 (("PATH=\"\\$\\{path4sdk\\}\"")
596 (string-append "PATH=" (getenv "PATH")))
597 (("make=/usr/bin/make")
598 (string-append "make=" (which "make"))))
599 (substitute* '("runtime/6626217/Test6626217.sh"
600 "runtime/7110720/Test7110720.sh")
601 (("/bin/rm") (which "rm"))
602 (("/bin/cp") (which "cp"))
603 (("/bin/mv") (which "mv"))))
605 (add-before 'check 'fix-jdk-tests
607 (with-directory-excursion "openjdk.src/jdk/test/"
608 (substitute* "com/sun/jdi/JdbReadTwiceTest.sh"
609 (("/bin/pwd") (which "pwd")))
610 (substitute* "com/sun/jdi/ShellScaffold.sh"
611 (("/bin/kill") (which "kill")))
612 (substitute* "start-Xvfb.sh"
613 ;;(("/usr/bin/X11/Xvfb") (which "Xvfb"))
614 (("/usr/bin/nohup") (which "nohup")))
615 (substitute* "javax/security/auth/Subject/doAs/Test.sh"
616 (("/bin/rm") (which "rm")))
617 (substitute* "tools/launcher/MultipleJRE.sh"
618 (("echo \"#!/bin/sh\"")
619 (string-append "echo \"#!" (which "rm") "\""))
620 (("/usr/bin/zip") (which "zip")))
621 (substitute* "com/sun/jdi/OnThrowTest.java"
622 (("#!/bin/sh") (string-append "#!" (which "sh"))))
623 (substitute* "java/lang/management/OperatingSystemMXBean/GetSystemLoadAverage.java"
624 (("/usr/bin/uptime") (which "uptime")))
625 (substitute* "java/lang/ProcessBuilder/Basic.java"
626 (("/usr/bin/env") (which "env"))
627 (("/bin/false") (which "false"))
628 (("/bin/true") (which "true"))
629 (("/bin/cp") (which "cp"))
630 (("/bin/sh") (which "sh")))
631 (substitute* "java/lang/ProcessBuilder/FeelingLucky.java"
632 (("/bin/sh") (which "sh")))
633 (substitute* "java/lang/ProcessBuilder/Zombies.java"
634 (("/usr/bin/perl") (which "perl"))
635 (("/bin/ps") (which "ps"))
636 (("/bin/true") (which "true")))
637 (substitute* "java/lang/Runtime/exec/ConcurrentRead.java"
638 (("/usr/bin/tee") (which "tee")))
639 (substitute* "java/lang/Runtime/exec/ExecWithDir.java"
640 (("/bin/true") (which "true")))
641 (substitute* "java/lang/Runtime/exec/ExecWithInput.java"
642 (("/bin/cat") (which "cat")))
643 (substitute* "java/lang/Runtime/exec/ExitValue.java"
644 (("/bin/sh") (which "sh"))
645 (("/bin/true") (which "true"))
646 (("/bin/kill") (which "kill")))
647 (substitute* "java/lang/Runtime/exec/LotsOfDestroys.java"
648 (("/usr/bin/echo") (which "echo")))
649 (substitute* "java/lang/Runtime/exec/LotsOfOutput.java"
650 (("/usr/bin/cat") (which "cat")))
651 (substitute* "java/lang/Runtime/exec/SleepyCat.java"
652 (("/bin/cat") (which "cat"))
653 (("/bin/sleep") (which "sleep"))
654 (("/bin/sh") (which "sh")))
655 (substitute* "java/lang/Runtime/exec/StreamsSurviveDestroy.java"
656 (("/bin/cat") (which "cat")))
657 (substitute* "java/rmi/activation/CommandEnvironment/SetChildEnv.java"
658 (("/bin/chmod") (which "chmod")))
659 (substitute* "java/util/zip/ZipFile/Assortment.java"
660 (("/bin/sh") (which "sh"))))
664 ;; The "make check-*" targets always return zero, so we need to
665 ;; check for errors in the associated log files to determine
666 ;; whether any tests have failed.
667 (use-modules (ice-9 rdelim))
668 (let* ((error-pattern (make-regexp "^(Error|FAILED):.*"))
669 (checker (lambda (port)
671 (let ((line (read-line port)))
673 ((eof-object? line) #t)
674 ((regexp-exec error-pattern line) #f)
676 (run-test (lambda (test)
677 (system* "make" test)
678 (call-with-input-file
679 (string-append "test/" test ".log")
682 (and (run-test "check-hotspot")
683 (run-test "check-langtools")
684 (run-test "check-jdk"))))))
686 (lambda* (#:key outputs #:allow-other-keys)
687 (let ((doc (string-append (assoc-ref outputs "doc")
688 "/share/doc/icedtea"))
689 (jre (assoc-ref outputs "out"))
690 (jdk (assoc-ref outputs "jdk")))
691 (copy-recursively "openjdk.build/docs" doc)
692 (copy-recursively "openjdk.build/j2re-image" jre)
693 (copy-recursively "openjdk.build/j2sdk-image" jdk))
695 ;; By default IcedTea only generates an empty keystore. In order to
696 ;; be able to use certificates in Java programs we need to generate a
697 ;; keystore from a set of certificates. For convenience we use the
698 ;; certificates from the nss-certs package.
699 (add-after 'install 'install-keystore
700 (lambda* (#:key inputs outputs #:allow-other-keys)
701 (let* ((keystore "cacerts")
702 (certs-dir (string-append (assoc-ref inputs "nss-certs")
704 (keytool (string-append (assoc-ref outputs "jdk")
706 (define (extract-cert file target)
707 (call-with-input-file file
709 (call-with-output-file target
711 (let loop ((line (read-line in 'concat))
714 ((eof-object? line) #t)
715 ((string-prefix? "-----BEGIN" line)
717 (loop (read-line in 'concat) #t))
718 ((string-prefix? "-----END" line)
722 (when copying? (display line out))
723 (loop (read-line in 'concat) copying?)))))))))
724 (define (import-cert cert)
725 (format #t "Importing certificate ~a\n" (basename cert))
726 (let ((temp "tmpcert"))
727 (extract-cert cert temp)
728 (let ((port (open-pipe* OPEN_WRITE keytool
730 "-alias" (basename cert)
732 "-storepass" "changeit"
734 (display "yes\n" port)
735 (when (not (zero? (status:exit-val (close-pipe port))))
736 (format #t "failed to import ~a\n" cert)))
739 ;; This is necessary because the certificate directory contains
740 ;; files with non-ASCII characters in their names.
741 (setlocale LC_ALL "en_US.utf8")
742 (setenv "LC_ALL" "en_US.utf8")
744 (for-each import-cert (find-files certs-dir "\\.pem$"))
745 (mkdir-p (string-append (assoc-ref outputs "out")
747 (mkdir-p (string-append (assoc-ref outputs "jdk")
748 "/jre/lib/security"))
750 ;; The cacerts files we are going to overwrite are chmod'ed as
751 ;; read-only (444) in icedtea-8 (which derives from this
752 ;; package). We have to change this so we can overwrite them.
753 (chmod (string-append (assoc-ref outputs "out")
754 "/lib/security/" keystore) #o644)
755 (chmod (string-append (assoc-ref outputs "jdk")
756 "/jre/lib/security/" keystore) #o644)
758 (install-file keystore
759 (string-append (assoc-ref outputs "out")
761 (install-file keystore
762 (string-append (assoc-ref outputs "jdk")
763 "/jre/lib/security"))
768 "08a4d1sg5m9l99lc7gafc7dmzmf4d8jvij5pffxv8rf6pk7psk24"))
771 "12br49cfrqgvms0bnaij7fvnakvb6q8dlpqja64rg5q5r3x4gps8"))
774 "07v2y3pll6z2wma94qilgffwyn2n4jna01mrhqwkb27whfpjfkmz"))
777 "18rw64jjpq14v56d0q1xvz8knl0kf02rcday7fvlaxrbbj19km55"))
780 "1ig7xipi3vzm6cphy5fdraxi72p27xsg2qb51yqx9qwsmlrv1zj4"))
783 "0sn9qv9nnhaan2smbhrv54lfhwsjhgd3b3h736p5d2hzpw8kicry"))
786 "16ijxy8br8dla339m4i90wr9xpf7s8z3nrhfyxm7jahr8injpzyl"))
789 ("autoconf" ,autoconf)
790 ("automake" ,automake)
791 ("coreutils" ,coreutils)
792 ("diffutils" ,diffutils) ;for tests
796 ("pkg-config" ,pkg-config)
803 ("libxslt" ,libxslt) ;for xsltproc
804 ("nss-certs" ,nss-certs)
806 ("procps" ,procps) ;for "free", even though I'm not sure we should use it
809 `(("alsa-lib" ,alsa-lib)
812 ("libxcomposite" ,libxcomposite)
816 ("libxinerama" ,libxinerama)
817 ("libxrender" ,libxrender)
820 ("mit-krb5" ,mit-krb5)
823 ("fontconfig" ,fontconfig)
824 ("freetype" ,freetype)
828 (home-page "http://icedtea.classpath.org")
829 (synopsis "Java development kit")
831 "This package provides the Java development kit OpenJDK built with the
832 IcedTea build harness.")
833 ;; IcedTea is released under the GPL2 + Classpath exception, which is the
834 ;; same license as both GNU Classpath and OpenJDK.
835 (license license:gpl2+))))
837 (define-public icedtea-8
838 (let* ((version "3.3.0")
839 (drop (lambda (name hash)
843 "http://icedtea.classpath.org/download/drops/"
844 "/icedtea8/" version "/" name ".tar.xz"))
845 (sha256 (base32 hash))))))
846 (package (inherit icedtea-7)
851 "http://icedtea.wildebeest.org/download/source/icedtea-"
855 "02vmxa6gc6gizcri1fy797qmmm9y77vgi7gy9pwkk4agcw4zyr5p"))
856 (modules '((guix build utils)))
859 (substitute* "acinclude.m4"
860 ;; Do not embed build time
861 (("(DIST_ID=\"Custom build).*$" _ prefix)
862 (string-append prefix "\"\n"))
863 ;; Do not leak information about the build host
864 (("DIST_NAME=\"\\$build_os\"")
865 "DIST_NAME=\"guix\""))
868 (substitute-keyword-arguments (package-arguments icedtea-7)
869 ((#:configure-flags flags)
870 `(let ((jdk (assoc-ref %build-inputs "jdk")))
871 `(;;"--disable-bootstrap"
874 "--disable-downloading"
875 "--disable-system-pcsc"
876 "--disable-system-sctp"
877 "--disable-tests" ;they are run in the check phase instead
878 "--with-openjdk-src-dir=./openjdk.src"
879 ,(string-append "--with-jdk-home=" jdk))))
881 `(modify-phases ,phases
882 (delete 'fix-x11-extension-include-path)
883 (delete 'patch-paths)
884 (delete 'set-additional-paths)
885 (delete 'patch-patches)
886 (add-after 'unpack 'patch-jni-libs
887 ;; Hardcode dynamically loaded libraries.
889 (let* ((library-path (search-path-as-string->list
890 (getenv "LIBRARY_PATH")))
891 (find-library (lambda (name)
894 (string-append "lib" name ".so")))))
897 (catch 'encoding-error
900 (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)"
902 (format #f "\"~a\"" (find-library name)))
903 (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name)
904 (format #f "\"~a\"" (find-library name)))))
906 ;; Those are safe to skip.
907 (format (current-error-port)
908 "warning: failed to substitute: ~a~%"
910 (find-files "openjdk.src/jdk/src/solaris/native"
914 (lambda* (#:key outputs #:allow-other-keys)
915 (let ((doc (string-append (assoc-ref outputs "doc")
916 "/share/doc/icedtea"))
917 (jre (assoc-ref outputs "out"))
918 (jdk (assoc-ref outputs "jdk")))
919 (copy-recursively "openjdk.build/docs" doc)
920 (copy-recursively "openjdk.build/images/j2re-image" jre)
921 (copy-recursively "openjdk.build/images/j2sdk-image" jdk)
924 `(("jdk" ,icedtea-7 "jdk")
927 "0889n19w6rvpzxgmmk9hlgzdh9ya95qkc2ajgpnzr3h69g15nz48"))
930 "0qcb72hhlsjgp6h9wd048qgyc88b7lfnxyc51xfyav0nhpfjnj8r"))
933 "1vyc7dw10x5k45jmi348y8min6sg651ns12zzn30fjzhpfi36nds"))
936 "1dki6p39z1ms94cjvj5hd9q75q75g244c0xib82pma3q74jg6hx4"))
939 "17czby3nylcglp7l3d90a4pz1izc1sslifv8hrmynm9hn4m9d3k8"))
942 "1h4azc21k58g9gn2y686wrvn9ahgac0ii7jhrrrmb5c1kjs0y2qv"))
945 "12bfgwhrjfhgj6a2dsysdwhirg0jx88pi44y7s8a1bdan1mp03r8"))
948 "0bg9r16jffc64fhyczn4jpx7bkfw7w62prw65mh66vshqk4lbh0f"))
951 "0abjlsvz669i06mlks28wnh11mm55y5613990pn5j7hfbw8a34q5"))
952 ,@(fold alist-delete (package-native-inputs icedtea-7)
953 '("gcj" "openjdk-src" "corba-drop" "jaxp-drop" "jaxws-drop"
954 "jdk-drop" "langtools-drop" "hotspot-drop")))))))
956 (define-public icedtea icedtea-7)
958 (define-public java-xz
964 (uri (string-append "http://tukaani.org/xz/xz-java-" version ".zip"))
967 "1z3p1ri1gvl07inxn0agx44ck8n7wrzfmvkz8nbq3njn8r9wba8x"))))
968 (build-system ant-build-system)
970 `(#:tests? #f ; There are no tests to run.
971 #:jar-name ,(string-append "xz-" version ".jar")
973 (modify-phases %standard-phases
974 ;; The unpack phase enters the "maven" directory by accident.
975 (add-after 'unpack 'chdir
976 (lambda _ (chdir "..") #t)))))
979 (home-page "http://tukaani.org/xz/java.html")
980 (synopsis "Implementation of XZ data compression in pure Java")
981 (description "This library aims to be a complete implementation of XZ data
982 compression in pure Java. Single-threaded streamed compression and
983 decompression and random access decompression have been fully implemented.")
984 (license license:public-domain)))
986 ;; java-hamcrest-core uses qdox version 1.12. We package this version instead
987 ;; of the latest release.
988 (define-public java-qdox-1.12
994 (uri (string-append "http://central.maven.org/maven2/"
995 "com/thoughtworks/qdox/qdox/" version
996 "/qdox-" version "-sources.jar"))
999 "0hlfbqq2avf5s26wxkksqmkdyk6zp9ggqn37c468m96mjv0n9xfl"))))
1000 (build-system ant-build-system)
1002 `(;; Tests require junit
1004 #:jar-name "qdox.jar"
1006 (modify-phases %standard-phases
1008 (lambda* (#:key source #:allow-other-keys)
1010 (with-directory-excursion "src"
1011 (zero? (system* "jar" "-xf" source)))))
1012 ;; At this point we don't have junit, so we must remove the API
1014 (add-after 'unpack 'delete-tests
1016 (delete-file-recursively "src/com/thoughtworks/qdox/junit")
1018 (home-page "http://qdox.codehaus.org/")
1019 (synopsis "Parse definitions from Java source files")
1021 "QDox is a high speed, small footprint parser for extracting
1022 class/interface/method definitions from source files complete with JavaDoc
1023 @code{@@tags}. It is designed to be used by active code generators or
1024 documentation tools.")
1025 (license license:asl2.0)))
1027 (define-public java-jarjar
1029 (name "java-jarjar")
1034 "https://storage.googleapis.com/google-code-archive-downloads/v2/"
1035 "code.google.com/jarjar/jarjar-src-" version ".zip"))
1038 "1v8irhni9cndcw1l1wxqgry013s2kpj0qqn57lj2ji28xjq8ndjl"))))
1039 (build-system ant-build-system)
1041 `(;; Tests require junit, which ultimately depends on this package.
1043 #:build-target "jar"
1045 (modify-phases %standard-phases
1047 (lambda* (#:key outputs #:allow-other-keys)
1048 (let ((target (string-append (assoc-ref outputs "out")
1050 (install-file (string-append "dist/jarjar-" ,version ".jar")
1054 `(("unzip" ,unzip)))
1055 (home-page "https://code.google.com/archive/p/jarjar/")
1056 (synopsis "Repackage Java libraries")
1058 "Jar Jar Links is a utility that makes it easy to repackage Java
1059 libraries and embed them into your own distribution. Jar Jar Links includes
1060 an Ant task that extends the built-in @code{jar} task.")
1061 (license license:asl2.0)))
1063 (define-public java-hamcrest-core
1065 (name "java-hamcrest-core")
1069 (uri (string-append "https://github.com/hamcrest/JavaHamcrest/"
1070 "archive/hamcrest-java-" version ".tar.gz"))
1073 "11g0s105fmwzijbv08lx8jlb521yravjmxnpgdx08fvg1kjivhva"))
1074 (modules '((guix build utils)))
1077 ;; Delete bundled thirds-party jar archives.
1078 (delete-file-recursively "lib")
1080 (build-system ant-build-system)
1082 `(#:tests? #f ; Tests require junit
1083 #:make-flags (list (string-append "-Dversion=" ,version))
1084 #:build-target "core"
1086 (modify-phases %standard-phases
1087 ;; Disable unit tests, because they require junit, which requires
1088 ;; hamcrest-core. We also give a fixed value to the "Built-Date"
1089 ;; attribute from the manifest for reproducibility.
1090 (add-before 'configure 'patch-build.xml
1092 (substitute* "build.xml"
1093 (("unit-test, ") "")
1094 (("\\$\\{build.timestamp\\}") "guix"))
1096 ;; Java's "getMethods()" returns methods in an unpredictable order.
1097 ;; To make the output of the generated code deterministic we must
1098 ;; sort the array of methods.
1099 (add-after 'unpack 'make-method-order-deterministic
1101 (substitute* "hamcrest-generator/src/main/java/org/hamcrest/generator/ReflectiveFactoryReader.java"
1102 (("import java\\.util\\.Iterator;" line)
1103 (string-append line "\n"
1104 "import java.util.Arrays; import java.util.Comparator;"))
1105 (("allMethods = cls\\.getMethods\\(\\);" line)
1106 (string-append "_" line
1108 private Method[] getSortedMethods() {
1109 Arrays.sort(_allMethods, new Comparator<Method>() {
1111 public int compare(Method a, Method b) {
1112 return a.toString().compareTo(b.toString());
1118 private Method[] allMethods = getSortedMethods();")))))
1119 (add-before 'build 'do-not-use-bundled-qdox
1120 (lambda* (#:key inputs #:allow-other-keys)
1121 (substitute* "build.xml"
1122 (("lib/generator/qdox-1.12.jar")
1123 (string-append (assoc-ref inputs "java-qdox-1.12")
1124 "/share/java/qdox.jar")))
1126 ;; build.xml searches for .jar files in this directoy, which
1127 ;; we remove from the source archive.
1128 (add-before 'build 'create-dummy-directories
1130 (mkdir-p "lib/integration")
1133 (lambda* (#:key outputs #:allow-other-keys)
1134 (install-file (string-append "build/hamcrest-core-"
1136 (string-append (assoc-ref outputs "out")
1137 "/share/java")))))))
1139 `(("java-qdox-1.12" ,java-qdox-1.12)
1140 ("java-jarjar" ,java-jarjar)))
1141 (home-page "http://hamcrest.org/")
1142 (synopsis "Library of matchers for building test expressions")
1144 "This package provides a library of matcher objects (also known as
1145 constraints or predicates) allowing @code{match} rules to be defined
1146 declaratively, to be used in other frameworks. Typical scenarios include
1147 testing frameworks, mocking libraries and UI validation rules.")
1148 (license license:bsd-2)))
1150 (define-public java-junit
1156 (uri (string-append "https://github.com/junit-team/junit/"
1157 "archive/r" version ".tar.gz"))
1158 (file-name (string-append name "-" version ".tar.gz"))
1161 "090dn5v1vs0b3acyaqc0gjf6p8lmd2h24wfzsbq7sly6b214anws"))
1162 (modules '((guix build utils)))
1165 ;; Delete bundled jar archives.
1166 (delete-file-recursively "lib")
1168 (build-system ant-build-system)
1170 `(#:tests? #f ; no tests
1171 #:jar-name "junit.jar"))
1173 `(("java-hamcrest-core" ,java-hamcrest-core)))
1174 (home-page "http://junit.org/")
1175 (synopsis "Test framework for Java")
1177 "JUnit is a simple framework to write repeatable tests for Java projects.
1178 JUnit provides assertions for testing expected results, test fixtures for
1179 sharing common test data, and test runners for running tests.")
1180 (license license:epl1.0)))