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>
6 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
59 (define-public java-swt
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")
73 (let-values (((hash file)
74 (match (or (%current-target-system) (%current-system))
75 ("x86_64-linux" (values hash64 file64))
76 (_ (values hash32 file32)))))
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)
86 `(#:jar-name "swt.jar"
87 #:tests? #f ; no "check" target
89 (modify-phases %standard-phases
91 (lambda* (#:key source #:allow-other-keys)
93 (zero? (system* "unzip" source "-d" "swt"))
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
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
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$"))
120 `(("xulrunner" ,icecat)
127 `(("pkg-config" ,pkg-config)
129 (home-page "https://www.eclipse.org/swt/")
130 (synopsis "Widget toolkit for Java")
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
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
145 (define-public clojure
146 (let* ((remove-archives '(begin
147 (for-each delete-file
148 (find-files "." ".*\\.(jar|zip)"))
150 (submodule (lambda (prefix version hash)
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)))))
165 (string-append "http://repo1.maven.org/maven2/org/clojure/clojure/"
166 version "/clojure-" version ".zip"))
168 (base32 "1nip095fz5c492sw15skril60i1vd21ibg6szin4jcvyy3xr6cym"))
169 (modules '((guix build utils)))
170 (snippet remove-archives)))
171 (build-system ant-build-system)
173 `(#:modules ((guix build ant-build-system)
181 (modify-phases %standard-phases
182 (add-after 'unpack 'unpack-submodule-sources
183 (lambda* (#:key inputs #:allow-other-keys)
187 (with-directory-excursion name
188 (or (zero? (system* "tar"
189 ;; Use xz for repacked tarball.
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/")
198 '("data-generators-src"
201 "test-generative-src"
202 "tools-namespace-src"
205 ;; The javadoc target is not built by default.
206 (add-after 'build 'build-doc
208 (zero? (system* "ant" "javadoc"))))
209 ;; Needed since no install target is provided.
211 (lambda* (#:key outputs #:allow-other-keys)
212 (let ((java-dir (string-append (assoc-ref outputs "out")
214 ;; Install versioned to avoid collisions.
215 (install-file (string-append "clojure-" ,version ".jar")
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-"
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)"
233 ;; The native-inputs below are needed to run the tests.
235 `(("data-generators-src"
236 ,(submodule "data.generators/archive/data.generators-"
238 "0kki093jp4ckwxzfnw8ylflrfqs8b1i1wi9iapmwcsy328dmgzp1"))
239 ("java-classpath-src"
240 ,(submodule "java.classpath/archive/java.classpath-"
242 "0sjymly9xh1lkvwn5ygygpsfwz4dabblnlq0c9bx76rkvq62fyng"))
244 ,(submodule "test.check/archive/test.check-"
246 "0p0mnyhr442bzkz0s4k5ra3i6l5lc7kp6ajaqkkyh4c2k5yck1md"))
247 ("test-generative-src"
248 ,(submodule "test.generative/archive/test.generative-"
250 "1pjafy1i7yblc7ixmcpfq1lfbyf3jaljvkgrajn70sws9xs7a9f8"))
251 ("tools-namespace-src"
252 ,(submodule "tools.namespace/archive/tools.namespace-"
254 "10baak8v0hnwz2hr33bavshm7y49mmn9zsyyms1dwjz45p5ymhy0"))
256 ,(submodule "tools.reader/archive/tools.reader-"
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.
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
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
280 ;; See readme.html or readme.txt for details.
281 (license (list license:epl1.0
292 (uri (string-append "mirror://apache/ant/source/apache-ant-"
293 version "-src.tar.gz"))
296 "1396wflczyxjxl603dhxjvd559f289lha9y2f04f71c7hapjl3am"))))
297 (build-system gnu-build-system)
299 `(#:tests? #f ; no "check" target
302 'unpack 'remove-scripts
303 ;; Remove bat / cmd scripts for DOS as well as the antRun and runant
306 (for-each delete-file
307 (find-files "src/script"
308 "(.*\\.(bat|cmd)|runant.*|antRun.*)")))
312 (setenv "JAVA_HOME" (string-append (assoc-ref %build-inputs "gcj")
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")))))
325 (alist-delete 'install %standard-phases))))))
328 (home-page "http://ant.apache.org")
329 (synopsis "Build tool for Java")
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)))
337 (define-public icedtea-6
344 "http://icedtea.wildebeest.org/download/source/icedtea6-"
348 "1q5iqm3dzqj8w3dwj6qqhczkkrslrfhmn3110klfwq9kyi2nimj8"))
349 (modules '((guix build utils)))
351 '(substitute* "Makefile.in"
352 ;; link against libgcj to avoid linker error
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
363 `(;; There are many failing tests and many are known to fail upstream.
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
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
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
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.
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
403 #:modules ((guix build utils)
404 (guix build gnu-build-system)
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"
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")))
426 (modify-phases %standard-phases
428 (lambda* (#:key source inputs #:allow-other-keys)
429 (and (zero? (system* "tar" "xvf" source))
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
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"))))
444 (add-after 'unpack 'patch-paths
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")))
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"))))
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")))
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")
482 (string-append "ECHO = " (which "echo")))
484 (string-append "GREP = " (which "grep")))
486 (string-append "EGREP = " (which "egrep")))
488 (string-append "CPIO = " (which "cpio")))
489 (("READELF *=.*readelf")
490 (string-append "READELF = " (which "readelf")))
492 (string-append "AR = " (which "ar")))
494 (string-append "TAR = " (which "tar")))
496 (string-append "AS = " (which "as")))
498 (string-append "LD = " (which "ld")))
500 (string-append "STRIP = " (which "strip")))
502 (string-append "NM = " (which "nm")))
504 (string-append "SH = " (which "bash")))
506 (string-append "FIND = " (which "find")))
508 (string-append "LDD = " (which "ldd")))
509 (("NAWK *=.*(n|g)awk")
510 (string-append "NAWK = " (which "gawk")))
512 (string-append "XARGS = " (which "xargs")))
514 (string-append "UNZIP = " (which "unzip")))
516 (string-append "ZIPEXE = " (which "zip")))
518 (string-append "SED = " (which "sed"))))
520 ;; Some of these timestamps cause problems as they are more than
521 ;; 10 years ago, failing the build process.
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)))
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")
550 (setenv "ALT_FREETYPE_HEADERS_PATH"
551 (string-append (assoc-ref %build-inputs "freetype")
553 (setenv "ALT_FREETYPE_LIB_PATH"
554 (string-append (assoc-ref %build-inputs "freetype")
556 (add-before 'check 'fix-test-framework
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")))
565 (add-before 'check 'fix-hotspot-tests
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"))))
579 (add-before 'check 'fix-jdk-tests
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"))))
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)
645 (let ((line (read-line port)))
647 ((eof-object? line) #t)
648 ((regexp-exec error-pattern line) #f)
650 (run-test (lambda (test)
651 (system* "make" test)
652 (call-with-input-file
653 (string-append "test/" test ".log")
656 (and (run-test "check-hotspot")
657 (run-test "check-langtools")
658 (run-test "check-jdk"))))))
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")
677 (keytool (string-append (assoc-ref outputs "jdk")
679 (define (extract-cert file target)
680 (call-with-input-file file
682 (call-with-output-file target
684 (let loop ((line (read-line in 'concat))
687 ((eof-object? line) #t)
688 ((string-prefix? "-----BEGIN" line)
690 (loop (read-line in 'concat) #t))
691 ((string-prefix? "-----END" line)
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
703 "-alias" (basename cert)
705 "-storepass" "changeit"
707 (display "yes\n" port)
708 (when (not (zero? (status:exit-val (close-pipe port))))
709 (error "failed to import" cert)))
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")
717 (for-each import-cert (find-files certs-dir "\\.pem$"))
718 (mkdir-p (string-append (assoc-ref outputs "out")
720 (mkdir-p (string-append (assoc-ref outputs "jdk")
721 "/jre/lib/security"))
722 (install-file keystore
723 (string-append (assoc-ref outputs "out")
725 (install-file keystore
726 (string-append (assoc-ref outputs "jdk")
727 "/jre/lib/security"))
731 ("alsa-lib" ,alsa-lib)
733 ("autoconf" ,autoconf)
734 ("automake" ,automake)
735 ("coreutils" ,coreutils)
736 ("diffutils" ,diffutils) ;for tests
740 ("pkg-config" ,pkg-config)
748 ("libxslt" ,libxslt) ;for xsltproc
749 ("mit-krb5" ,mit-krb5)
751 ("nss-certs" ,nss-certs)
753 ("libxcomposite" ,libxcomposite)
757 ("libxinerama" ,libxinerama)
758 ("libxrender" ,libxrender)
763 ("procps" ,procps) ;for "free", even though I'm not sure we should use it
767 (uri "https://java.net/downloads/openjdk6/openjdk-6-src-b40-22_aug_2016.tar.gz")
770 "01v4q7g9pa6w7m6yxply5yrin08jgv12fck665xnmp09bpxy8sa5"))))
774 ("fontconfig" ,fontconfig)
775 ("freetype" ,freetype)
777 (home-page "http://icedtea.classpath.org")
778 (synopsis "Java development kit")
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+)))
785 (define-public icedtea-7
786 (let* ((version "2.6.7")
787 (drop (lambda (name hash)
791 "http://icedtea.classpath.org/download/drops/"
792 "/icedtea7/" version "/" name ".tar.bz2"))
793 (sha256 (base32 hash))))))
794 (package (inherit icedtea-6)
799 "http://icedtea.wildebeest.org/download/source/icedtea-"
803 "1r4y1afjdm72j4lkd1jsim595zy5s3hvc3dnl13f5a7wrxp2v4nh"))
804 (modules '((guix build utils)))
806 '(substitute* "Makefile.in"
807 ;; link against libgcj to avoid linker error
809 "-lgcj -o native-ecj")
810 ;; do not leak information about the build host
811 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
812 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
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.
819 ;; hotspot: passed: 241; failed: 45; error: 2
820 ;; langtools: passed: 1,934; failed: 26
823 ;; Apparently, the C locale is needed for some of the tests.
825 ,@(substitute-keyword-arguments (package-arguments icedtea-6)
830 ((#:configure-flags flags)
831 ;; TODO: package pcsc and sctp, and add to inputs
832 `(append '("--disable-system-pcsc"
833 "--disable-system-sctp")
836 `(modify-phases ,phases
838 (lambda* (#:key source inputs #:allow-other-keys)
839 (let ((target (string-append "icedtea-" ,version))
840 (unpack (lambda* (name #:optional dir)
842 (string-drop-right name 5))))
844 (zero? (system* "tar" "xvf"
845 (assoc-ref inputs name)
847 "--strip-components=1"))))))
850 (zero? (system* "tar" "xvf" source
851 "-C" target "--strip-components=1"))
853 (unpack "openjdk-src" "openjdk.src")
854 (with-directory-excursion "openjdk.src"
856 (filter (cut string-suffix? "-drop" <>)
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)))
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")))
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")
891 (setenv "ALT_FREETYPE_HEADERS_PATH"
892 (string-append (assoc-ref inputs "freetype")
894 (setenv "ALT_FREETYPE_LIB_PATH"
895 (string-append (assoc-ref inputs "freetype")
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\\)\\)") ""))
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")))
926 (delete 'patch-patches))))))
930 "0y38vgvzw2xggfg0nlalv42amy5sv6vzvjxik8bvkm1sajzazb2w"))
933 "0r778nhmzcnf6jkl50f6f279vbzh96rcwr74vb0930wgl2g46j80"))
936 "02y7zaw4irjvbihpr4pbrl64pxjx5anfxms3i24rp1q6aj2n1gcz"))
939 "1xrhdgykpi7amyyirzchp4mjrx2j3xm6nqg4bbfy2kxv7daw3z69"))
942 "108d560iabk334lcifr5xf1w075a6c918smpbcaccsrln8qd6g79"))
945 "1r5llvhxzdihyz6rmr6ri9wz8zvbw4gmlllhb340p86liqqh1rqk"))
948 "0p3arg01jfdnbx856qfhhzp7s9yzmqwa1fspk5spmmxb9m7mj4h4"))
949 ,@(fold alist-delete (package-native-inputs icedtea-6)
952 `(("libxcomposite" ,libxcomposite)
953 ,@(package-inputs icedtea-6))))))
955 (define-public icedtea-8
956 (let* ((version "3.1.0")
957 (drop (lambda (name hash)
961 "http://icedtea.classpath.org/download/drops/"
962 "/icedtea8/" version "/" name ".tar.xz"))
963 (sha256 (base32 hash))))))
964 (package (inherit icedtea-7)
969 "http://icedtea.wildebeest.org/download/source/icedtea-"
973 "1d1kj8a6jbvcbzhmfrx2pca7pinsvpxd7zij9h93g13dmm0ncqbm"))
974 (modules '((guix build utils)))
976 '(substitute* "Makefile.am"
977 ;; do not leak information about the build host
978 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
979 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
981 (substitute-keyword-arguments (package-arguments icedtea-7)
982 ((#:configure-flags flags)
983 `(let ((jdk (assoc-ref %build-inputs "jdk")))
984 `(;;"--disable-bootstrap"
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))))
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 (add-after 'unpack 'patch-jni-libs
998 ;; Hardcode dynamically loaded libraries.
1000 (let* ((library-path (search-path-as-string->list
1001 (getenv "LIBRARY_PATH")))
1002 (find-library (lambda (name)
1005 (string-append "lib" name ".so")))))
1008 (catch 'encoding-error
1011 (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)"
1013 (format #f "\"~a\"" (find-library name)))
1014 (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name)
1015 (format #f "\"~a\"" (find-library name)))))
1017 ;; Those are safe to skip.
1018 (format (current-error-port)
1019 "warning: failed to substitute: ~a~%"
1021 (find-files "openjdk.src/jdk/src/solaris/native"
1024 ;; FIXME: This phase is needed but fails with this version of
1026 (delete 'install-keystore)
1028 (lambda* (#:key outputs #:allow-other-keys)
1029 (let ((doc (string-append (assoc-ref outputs "doc")
1030 "/share/doc/icedtea"))
1031 (jre (assoc-ref outputs "out"))
1032 (jdk (assoc-ref outputs "jdk")))
1033 (copy-recursively "openjdk.build/docs" doc)
1034 (copy-recursively "openjdk.build/images/j2re-image" jre)
1035 (copy-recursively "openjdk.build/images/j2sdk-image" jdk)
1038 `(("jdk" ,icedtea-7 "jdk")
1041 "1p6xgf00w754y3xdrccs67gjhb0181q49dk67h5v43aixkx7z7y1"))
1044 "088wnyfdhqkvc41pl3swnynbxx7x5lha6qg7q0biai6ya114scsy"))
1047 "18xc4sib85z2zhz4k5lvi5b4vn88zqjpa3wi8gav81vz5gyysn3d"))
1050 "1my72q2zjly4imn834zgf4rysn48gbr8i81rxzrfdqgzzinxf6l1"))
1053 "1ab2h7pppph82h3xhh1m5dha77j3wnhksq7c7f8yfcsyhr5hm243"))
1056 "07bzcw2ml4apjfd0ydc3v44fnnwinwri114fig2mdcn1n388szra"))
1059 "0x5ic8cz3w9s8m8ynh31qlf47c6nwc512bp8ddwgmvsdxyiiwn1k"))
1062 "0zyd8pyv1il8c9npw7wz1mwxhlq510ill20nhc7i8fq7gignzcsn"))
1065 "1shisljn60zw9j4nahh07vw85gj25gfiy7z196fdw0pi95va6qwk"))
1066 ,@(fold alist-delete (package-native-inputs icedtea-7)
1067 '("gcj" "openjdk-src" "corba-drop" "jaxp-drop" "jaxws-drop"
1068 "jdk-drop" "langtools-drop" "hotspot-drop")))))))
1070 (define-public icedtea icedtea-7)
1072 (define-public java-xz
1078 (uri (string-append "http://tukaani.org/xz/xz-java-" version ".zip"))
1081 "0x6vn9dp9kxk83x2fp3394n95dk8fx9yg8jns9371iqsn0vy8ih1"))))
1082 (build-system ant-build-system)
1084 `(#:tests? #f ; There are no tests to run.
1085 #:jar-name ,(string-append "xz-" version ".jar")
1087 (modify-phases %standard-phases
1088 ;; The unpack phase enters the "maven" directory by accident.
1089 (add-after 'unpack 'chdir
1090 (lambda _ (chdir "..") #t)))))
1092 `(("unzip" ,unzip)))
1093 (home-page "http://tukaani.org/xz/java.html")
1094 (synopsis "Implementation of XZ data compression in pure Java")
1095 (description "This library aims to be a complete implementation of XZ data
1096 compression in pure Java. Single-threaded streamed compression and
1097 decompression and random access decompression have been fully implemented.")
1098 (license license:public-domain)))
1100 ;; java-hamcrest-core uses qdox version 1.12. We package this version instead
1101 ;; of the latest release.
1102 (define-public java-qdox-1.12
1108 (uri (string-append "http://central.maven.org/maven2/"
1109 "com/thoughtworks/qdox/qdox/" version
1110 "/qdox-" version "-sources.jar"))
1113 "0hlfbqq2avf5s26wxkksqmkdyk6zp9ggqn37c468m96mjv0n9xfl"))))
1114 (build-system ant-build-system)
1116 `(;; Tests require junit
1118 #:jar-name "qdox.jar"
1120 (modify-phases %standard-phases
1122 (lambda* (#:key source #:allow-other-keys)
1124 (with-directory-excursion "src"
1125 (zero? (system* "jar" "-xf" source)))))
1126 ;; At this point we don't have junit, so we must remove the API
1128 (add-after 'unpack 'delete-tests
1130 (delete-file-recursively "src/com/thoughtworks/qdox/junit")
1132 (home-page "http://qdox.codehaus.org/")
1133 (synopsis "Parse definitions from Java source files")
1135 "QDox is a high speed, small footprint parser for extracting
1136 class/interface/method definitions from source files complete with JavaDoc
1137 @code{@@tags}. It is designed to be used by active code generators or
1138 documentation tools.")
1139 (license license:asl2.0)))
1141 (define-public java-jarjar
1143 (name "java-jarjar")
1148 "https://storage.googleapis.com/google-code-archive-downloads/v2/"
1149 "code.google.com/jarjar/jarjar-src-" version ".zip"))
1152 "1v8irhni9cndcw1l1wxqgry013s2kpj0qqn57lj2ji28xjq8ndjl"))))
1153 (build-system ant-build-system)
1155 `(;; Tests require junit, which ultimately depends on this package.
1157 #:build-target "jar"
1159 (modify-phases %standard-phases
1161 (lambda* (#:key outputs #:allow-other-keys)
1162 (let ((target (string-append (assoc-ref outputs "out")
1164 (install-file (string-append "dist/jarjar-" ,version ".jar")
1168 `(("unzip" ,unzip)))
1169 (home-page "https://code.google.com/archive/p/jarjar/")
1170 (synopsis "Repackage Java libraries")
1172 "Jar Jar Links is a utility that makes it easy to repackage Java
1173 libraries and embed them into your own distribution. Jar Jar Links includes
1174 an Ant task that extends the built-in @code{jar} task.")
1175 (license license:asl2.0)))
1177 (define-public java-hamcrest-core
1179 (name "java-hamcrest-core")
1183 (uri (string-append "https://github.com/hamcrest/JavaHamcrest/"
1184 "archive/hamcrest-java-" version ".tar.gz"))
1187 "11g0s105fmwzijbv08lx8jlb521yravjmxnpgdx08fvg1kjivhva"))
1188 (modules '((guix build utils)))
1191 ;; Delete bundled thirds-party jar archives.
1192 (delete-file-recursively "lib")
1194 (build-system ant-build-system)
1196 `(#:tests? #f ; Tests require junit
1197 #:make-flags (list (string-append "-Dversion=" ,version))
1198 #:build-target "core"
1200 (modify-phases %standard-phases
1201 ;; Disable unit tests, because they require junit, which requires
1202 ;; hamcrest-core. We also give a fixed value to the "Built-Date"
1203 ;; attribute from the manifest for reproducibility.
1204 (add-before 'configure 'patch-build.xml
1206 (substitute* "build.xml"
1207 (("unit-test, ") "")
1208 (("\\$\\{build.timestamp\\}") "guix"))
1210 ;; Java's "getMethods()" returns methods in an unpredictable order.
1211 ;; To make the output of the generated code deterministic we must
1212 ;; sort the array of methods.
1213 (add-after 'unpack 'make-method-order-deterministic
1215 (substitute* "hamcrest-generator/src/main/java/org/hamcrest/generator/ReflectiveFactoryReader.java"
1216 (("import java\\.util\\.Iterator;" line)
1217 (string-append line "\n"
1218 "import java.util.Arrays; import java.util.Comparator;"))
1219 (("allMethods = cls\\.getMethods\\(\\);" line)
1220 (string-append "_" line
1222 private Method[] getSortedMethods() {
1223 Arrays.sort(_allMethods, new Comparator<Method>() {
1225 public int compare(Method a, Method b) {
1226 return a.toString().compareTo(b.toString());
1232 private Method[] allMethods = getSortedMethods();")))))
1233 (add-before 'build 'do-not-use-bundled-qdox
1234 (lambda* (#:key inputs #:allow-other-keys)
1235 (substitute* "build.xml"
1236 (("lib/generator/qdox-1.12.jar")
1237 (string-append (assoc-ref inputs "java-qdox-1.12")
1238 "/share/java/qdox.jar")))
1240 ;; build.xml searches for .jar files in this directoy, which
1241 ;; we remove from the source archive.
1242 (add-before 'build 'create-dummy-directories
1244 (mkdir-p "lib/integration")
1247 (lambda* (#:key outputs #:allow-other-keys)
1248 (install-file (string-append "build/hamcrest-core-"
1250 (string-append (assoc-ref outputs "out")
1251 "/share/java")))))))
1253 `(("java-qdox-1.12" ,java-qdox-1.12)
1254 ("java-jarjar" ,java-jarjar)))
1255 (home-page "http://hamcrest.org/")
1256 (synopsis "Library of matchers for building test expressions")
1258 "This package provides a library of matcher objects (also known as
1259 constraints or predicates) allowing @code{match} rules to be defined
1260 declaratively, to be used in other frameworks. Typical scenarios include
1261 testing frameworks, mocking libraries and UI validation rules.")
1262 (license license:bsd-2)))
1264 (define-public java-junit
1270 (uri (string-append "https://github.com/junit-team/junit/"
1271 "archive/r" version ".tar.gz"))
1272 (file-name (string-append name "-" version ".tar.gz"))
1275 "090dn5v1vs0b3acyaqc0gjf6p8lmd2h24wfzsbq7sly6b214anws"))
1276 (modules '((guix build utils)))
1279 ;; Delete bundled jar archives.
1280 (delete-file-recursively "lib")
1282 (build-system ant-build-system)
1284 `(#:tests? #f ; no tests
1285 #:jar-name "junit.jar"))
1287 `(("java-hamcrest-core" ,java-hamcrest-core)))
1288 (home-page "http://junit.org/")
1289 (synopsis "Test framework for Java")
1291 "JUnit is a simple framework to write repeatable tests for Java projects.
1292 JUnit provides assertions for testing expected results, test fixtures for
1293 sharing common test data, and test runners for running tests.")
1294 (license license:epl1.0)))