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
151 (uri (string-append "mirror://apache/ant/source/apache-ant-"
152 version "-src.tar.gz"))
155 "1396wflczyxjxl603dhxjvd559f289lha9y2f04f71c7hapjl3am"))))
156 (build-system gnu-build-system)
158 `(#:tests? #f ; no "check" target
161 'unpack 'remove-scripts
162 ;; Remove bat / cmd scripts for DOS as well as the antRun and runant
165 (for-each delete-file
166 (find-files "src/script"
167 "(.*\\.(bat|cmd)|runant.*|antRun.*)")))
171 (setenv "JAVA_HOME" (string-append (assoc-ref %build-inputs "gcj")
173 ;; Disable tests to avoid dependency on hamcrest-core, which needs
174 ;; Ant to build. This is necessary in addition to disabling the
175 ;; "check" phase, because the dependency on "test-jar" would always
176 ;; result in the tests to be run.
177 (substitute* "build.xml"
178 (("depends=\"jars,test-jar\"") "depends=\"jars\""))
179 (zero? (system* "bash" "bootstrap.sh"
180 (string-append "-Ddist.dir="
181 (assoc-ref %outputs "out")))))
184 (alist-delete 'install %standard-phases))))))
187 (home-page "http://ant.apache.org")
188 (synopsis "Build tool for Java")
190 "Ant is a platform-independent build tool for Java. It is similar to
191 make but is implemented using the Java language, requires the Java platform,
192 and is best suited to building Java projects. Ant uses XML to describe the
193 build process and its dependencies, whereas Make uses Makefile format.")
194 (license license:asl2.0)))
196 (define-public icedtea-6
203 "http://icedtea.wildebeest.org/download/source/icedtea6-"
205 (patches (search-patches "icedtea-remove-overrides.patch"))
208 "1grki39a4rf8n74zc0iglcggxxbpniyfh1gk1lb10p63zvvcsvjj"))
209 (modules '((guix build utils)))
211 '(substitute* "Makefile.in"
212 ;; link against libgcj to avoid linker error
214 "-lgcj -o native-ecj")
215 ;; do not leak information about the build host
216 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
217 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
218 (build-system gnu-build-system)
219 (outputs '("out" ; Java Runtime Environment
220 "jdk" ; Java Development Kit
221 "doc")) ; all documentation
223 `(;; There are many failing tests and many are known to fail upstream.
225 ;; * Hotspot VM tests:
226 ;; FAILED: compiler/7082949/Test7082949.java
227 ;; FAILED: compiler/7088020/Test7088020.java
228 ;; FAILED: runtime/6929067/Test6929067.sh
229 ;; FAILED: serviceability/sa/jmap-hashcode/Test8028623.java
230 ;; => Test results: passed: 161; failed: 4
232 ;; * langtools tests:
233 ;; FAILED: com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
234 ;; FAILED: tools/javac/6627362/T6627362.java
235 ;; FAILED: tools/javac/7003595/T7003595.java
236 ;; FAILED: tools/javac/7024568/T7024568.java
237 ;; FAILED: tools/javap/4111861/T4111861.java
238 ;; FAILED: tools/javap/ListTest.java
239 ;; FAILED: tools/javap/OptionTest.java
240 ;; FAILED: tools/javap/T4884240.java
241 ;; FAILED: tools/javap/T4975569.java
242 ;; --> fails because of insignificant whitespace differences
243 ;; in output of javap
244 ;; FAILED: tools/javap/T6868539.java
245 ;; => Test results: passed: 1,445; failed: 10
248 ;; Tests are incomplete because of a segfault after this test:
249 ;; javax/crypto/spec/RC5ParameterSpec/RC5ParameterSpecEquals.java
250 ;; A bug report has already been filed upstream:
251 ;; http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2188
253 ;; The tests require xvfb-run, a wrapper script around Xvfb, which
254 ;; has not been packaged yet. Without it many AWT tests fail, so I
255 ;; made no attempts to make a list of failing JDK tests. At least
256 ;; 222 tests are failing of which at least 132 are AWT tests.
259 ;; The DSOs use $ORIGIN to refer to each other, but (guix build
260 ;; gremlin) doesn't support it yet, so skip this phase.
261 #:validate-runpath? #f
263 #:modules ((guix build utils)
264 (guix build gnu-build-system)
270 (let* ((gcjdir (assoc-ref %build-inputs "gcj"))
271 (ecj (string-append gcjdir "/share/java/ecj.jar"))
272 (jdk (string-append gcjdir "/lib/jvm/"))
273 (gcj (string-append gcjdir "/bin/gcj")))
274 `("--enable-bootstrap"
277 "--disable-downloading"
278 "--disable-tests" ;they are run in the check phase instead
279 "--with-openjdk-src-dir=./openjdk.src"
280 ,(string-append "--with-javac=" jdk "/bin/javac")
281 ,(string-append "--with-ecj-jar=" ecj)
282 ,(string-append "--with-gcj=" gcj)
283 ,(string-append "--with-jdk-home=" jdk)
284 ,(string-append "--with-java=" jdk "/bin/java")))
286 (modify-phases %standard-phases
288 (lambda* (#:key source inputs #:allow-other-keys)
289 (and (zero? (system* "tar" "xvf" source))
291 (chdir (string-append "icedtea6-" ,version))
292 (mkdir "openjdk.src")
293 (with-directory-excursion "openjdk.src"
294 (copy-file (assoc-ref inputs "openjdk6-src")
295 "openjdk6-src.tar.xz")
296 (zero? (system* "tar" "xvf" "openjdk6-src.tar.xz")))))))
297 (add-after 'unpack 'patch-patches
299 ;; shebang in patches so that they apply cleanly
300 (substitute* '("patches/jtreg-jrunscript.patch"
301 "patches/hotspot/hs23/drop_unlicensed_test.patch")
302 (("#!/bin/sh") (string-append "#!" (which "sh"))))
304 ;; fix path to alsa header in patch
305 (substitute* "patches/openjdk/6799141-split_out_versions.patch"
306 (("ALSA_INCLUDE=/usr/include/alsa/version.h")
307 (string-append "ALSA_INCLUDE="
308 (assoc-ref %build-inputs "alsa-lib")
309 "/include/alsa/version.h")))))
310 (add-after 'unpack 'patch-paths
312 ;; buildtree.make generates shell scripts, so we need to replace
313 ;; the generated shebang
314 (substitute* '("openjdk.src/hotspot/make/linux/makefiles/buildtree.make")
315 (("/bin/sh") (which "bash")))
317 (let ((corebin (string-append
318 (assoc-ref %build-inputs "coreutils") "/bin/"))
319 (binbin (string-append
320 (assoc-ref %build-inputs "binutils") "/bin/"))
321 (grepbin (string-append
322 (assoc-ref %build-inputs "grep") "/bin/")))
323 (substitute* '("openjdk.src/jdk/make/common/shared/Defs-linux.gmk"
324 "openjdk.src/corba/make/common/shared/Defs-linux.gmk")
325 (("UNIXCOMMAND_PATH = /bin/")
326 (string-append "UNIXCOMMAND_PATH = " corebin))
327 (("USRBIN_PATH = /usr/bin/")
328 (string-append "USRBIN_PATH = " corebin))
329 (("DEVTOOLS_PATH *= */usr/bin/")
330 (string-append "DEVTOOLS_PATH = " corebin))
331 (("COMPILER_PATH *= */usr/bin/")
332 (string-append "COMPILER_PATH = "
333 (assoc-ref %build-inputs "gcc") "/bin/"))
334 (("DEF_OBJCOPY *=.*objcopy")
335 (string-append "DEF_OBJCOPY = " (which "objcopy"))))
337 ;; fix hard-coded utility paths
338 (substitute* '("openjdk.src/jdk/make/common/shared/Defs-utils.gmk"
339 "openjdk.src/corba/make/common/shared/Defs-utils.gmk")
341 (string-append "ECHO = " (which "echo")))
343 (string-append "GREP = " (which "grep")))
345 (string-append "EGREP = " (which "egrep")))
347 (string-append "CPIO = " (which "cpio")))
348 (("READELF *=.*readelf")
349 (string-append "READELF = " (which "readelf")))
351 (string-append "AR = " (which "ar")))
353 (string-append "TAR = " (which "tar")))
355 (string-append "AS = " (which "as")))
357 (string-append "LD = " (which "ld")))
359 (string-append "STRIP = " (which "strip")))
361 (string-append "NM = " (which "nm")))
363 (string-append "SH = " (which "bash")))
365 (string-append "FIND = " (which "find")))
367 (string-append "LDD = " (which "ldd")))
368 (("NAWK *=.*(n|g)awk")
369 (string-append "NAWK = " (which "gawk")))
371 (string-append "XARGS = " (which "xargs")))
373 (string-append "UNZIP = " (which "unzip")))
375 (string-append "ZIPEXE = " (which "zip")))
377 (string-append "SED = " (which "sed"))))
379 ;; Some of these timestamps cause problems as they are more than
380 ;; 10 years ago, failing the build process.
382 "openjdk.src/jdk/src/share/classes/java/util/CurrencyData.properties"
383 (("AZ=AZM;2005-12-31-20-00-00;AZN") "AZ=AZN")
384 (("MZ=MZM;2006-06-30-22-00-00;MZN") "MZ=MZN")
385 (("RO=ROL;2005-06-30-21-00-00;RON") "RO=RON")
386 (("TR=TRL;2004-12-31-22-00-00;TRY") "TR=TRY")))))
387 (add-before 'configure 'set-additional-paths
388 (lambda* (#:key inputs #:allow-other-keys)
389 (let* ((gcjdir (assoc-ref %build-inputs "gcj"))
390 (gcjlib (string-append gcjdir "/lib"))
391 ;; Get target-specific include directory so that
392 ;; libgcj-config.h is found when compiling hotspot.
393 (gcjinclude (let* ((port (open-input-pipe "gcj -print-file-name=include"))
394 (str (read-line port)))
398 (string-append gcjinclude ":"
399 (assoc-ref %build-inputs "libxrender")
400 "/include/X11/extensions" ":"
401 (assoc-ref %build-inputs "libxtst")
402 "/include/X11/extensions" ":"
403 (assoc-ref %build-inputs "libxinerama")
404 "/include/X11/extensions" ":"
405 (or (getenv "CPATH") "")))
406 (setenv "ALT_CUPS_HEADERS_PATH"
407 (string-append (assoc-ref %build-inputs "cups")
409 (setenv "ALT_FREETYPE_HEADERS_PATH"
410 (string-append (assoc-ref %build-inputs "freetype")
412 (setenv "ALT_FREETYPE_LIB_PATH"
413 (string-append (assoc-ref %build-inputs "freetype")
415 (add-before 'check 'fix-test-framework
417 ;; Fix PATH in test environment
418 (substitute* "src/jtreg/com/sun/javatest/regtest/Main.java"
419 (("PATH=/bin:/usr/bin")
420 (string-append "PATH=" (getenv "PATH"))))
421 (substitute* "src/jtreg/com/sun/javatest/util/SysEnv.java"
422 (("/usr/bin/env") (which "env")))
424 (add-before 'check 'fix-hotspot-tests
426 (with-directory-excursion "openjdk.src/hotspot/test/"
427 (substitute* "jprt.config"
428 (("PATH=\"\\$\\{path4sdk\\}\"")
429 (string-append "PATH=" (getenv "PATH")))
430 (("make=/usr/bin/make")
431 (string-append "make=" (which "make"))))
432 (substitute* '("runtime/6626217/Test6626217.sh"
433 "runtime/7110720/Test7110720.sh")
434 (("/bin/rm") (which "rm"))
435 (("/bin/cp") (which "cp"))
436 (("/bin/mv") (which "mv"))))
438 (add-before 'check 'fix-jdk-tests
440 (with-directory-excursion "openjdk.src/jdk/test/"
441 (substitute* "com/sun/jdi/JdbReadTwiceTest.sh"
442 (("/bin/pwd") (which "pwd")))
443 (substitute* "com/sun/jdi/ShellScaffold.sh"
444 (("/bin/kill") (which "kill")))
445 (substitute* "start-Xvfb.sh"
446 ;;(("/usr/bin/X11/Xvfb") (which "Xvfb"))
447 (("/usr/bin/nohup") (which "nohup")))
448 (substitute* "javax/security/auth/Subject/doAs/Test.sh"
449 (("/bin/rm") (which "rm")))
450 (substitute* "tools/launcher/MultipleJRE.sh"
451 (("echo \"#!/bin/sh\"")
452 (string-append "echo \"#!" (which "rm") "\""))
453 (("/usr/bin/zip") (which "zip")))
454 (substitute* "com/sun/jdi/OnThrowTest.java"
455 (("#!/bin/sh") (string-append "#!" (which "sh"))))
456 (substitute* "java/lang/management/OperatingSystemMXBean/GetSystemLoadAverage.java"
457 (("/usr/bin/uptime") (which "uptime")))
458 (substitute* "java/lang/ProcessBuilder/Basic.java"
459 (("/usr/bin/env") (which "env"))
460 (("/bin/false") (which "false"))
461 (("/bin/true") (which "true"))
462 (("/bin/cp") (which "cp"))
463 (("/bin/sh") (which "sh")))
464 (substitute* "java/lang/ProcessBuilder/FeelingLucky.java"
465 (("/bin/sh") (which "sh")))
466 (substitute* "java/lang/ProcessBuilder/Zombies.java"
467 (("/usr/bin/perl") (which "perl"))
468 (("/bin/ps") (which "ps"))
469 (("/bin/true") (which "true")))
470 (substitute* "java/lang/Runtime/exec/ConcurrentRead.java"
471 (("/usr/bin/tee") (which "tee")))
472 (substitute* "java/lang/Runtime/exec/ExecWithDir.java"
473 (("/bin/true") (which "true")))
474 (substitute* "java/lang/Runtime/exec/ExecWithInput.java"
475 (("/bin/cat") (which "cat")))
476 (substitute* "java/lang/Runtime/exec/ExitValue.java"
477 (("/bin/sh") (which "sh"))
478 (("/bin/true") (which "true"))
479 (("/bin/kill") (which "kill")))
480 (substitute* "java/lang/Runtime/exec/LotsOfDestroys.java"
481 (("/usr/bin/echo") (which "echo")))
482 (substitute* "java/lang/Runtime/exec/LotsOfOutput.java"
483 (("/usr/bin/cat") (which "cat")))
484 (substitute* "java/lang/Runtime/exec/SleepyCat.java"
485 (("/bin/cat") (which "cat"))
486 (("/bin/sleep") (which "sleep"))
487 (("/bin/sh") (which "sh")))
488 (substitute* "java/lang/Runtime/exec/StreamsSurviveDestroy.java"
489 (("/bin/cat") (which "cat")))
490 (substitute* "java/rmi/activation/CommandEnvironment/SetChildEnv.java"
491 (("/bin/chmod") (which "chmod")))
492 (substitute* "java/util/zip/ZipFile/Assortment.java"
493 (("/bin/sh") (which "sh"))))
497 ;; The "make check-*" targets always return zero, so we need to
498 ;; check for errors in the associated log files to determine
499 ;; whether any tests have failed.
500 (use-modules (ice-9 rdelim))
501 (let* ((error-pattern (make-regexp "^(Error|FAILED):.*"))
502 (checker (lambda (port)
504 (let ((line (read-line port)))
506 ((eof-object? line) #t)
507 ((regexp-exec error-pattern line) #f)
509 (run-test (lambda (test)
510 (system* "make" test)
511 (call-with-input-file
512 (string-append "test/" test ".log")
515 (and (run-test "check-hotspot")
516 (run-test "check-langtools")
517 (run-test "check-jdk"))))))
519 (lambda* (#:key outputs #:allow-other-keys)
520 (let ((doc (string-append (assoc-ref outputs "doc")
521 "/share/doc/icedtea"))
522 (jre (assoc-ref outputs "out"))
523 (jdk (assoc-ref outputs "jdk")))
524 (copy-recursively "openjdk.build/docs" doc)
525 (copy-recursively "openjdk.build/j2re-image" jre)
526 (copy-recursively "openjdk.build/j2sdk-image" jdk))))
527 ;; By default IcedTea only generates an empty keystore. In order to
528 ;; be able to use certificates in Java programs we need to generate a
529 ;; keystore from a set of certificates. For convenience we use the
530 ;; certificates from the nss-certs package.
531 (add-after 'install 'install-keystore
532 (lambda* (#:key inputs outputs #:allow-other-keys)
533 (let* ((keystore "cacerts")
534 (certs-dir (string-append (assoc-ref inputs "nss-certs")
536 (keytool (string-append (assoc-ref outputs "jdk")
538 (define (extract-cert file target)
539 (call-with-input-file file
541 (call-with-output-file target
543 (let loop ((line (read-line in 'concat))
546 ((eof-object? line) #t)
547 ((string-prefix? "-----BEGIN" line)
549 (loop (read-line in 'concat) #t))
550 ((string-prefix? "-----END" line)
554 (when copying? (display line out))
555 (loop (read-line in 'concat) copying?)))))))))
556 (define (import-cert cert)
557 (format #t "Importing certificate ~a\n" (basename cert))
558 (let ((temp "tmpcert"))
559 (extract-cert cert temp)
560 (let ((port (open-pipe* OPEN_WRITE keytool
562 "-alias" (basename cert)
564 "-storepass" "changeit"
566 (display "yes\n" port)
567 (when (not (zero? (status:exit-val (close-pipe port))))
568 (error "failed to import" cert)))
571 ;; This is necessary because the certificate directory contains
572 ;; files with non-ASCII characters in their names.
573 (setlocale LC_ALL "en_US.utf8")
574 (setenv "LC_ALL" "en_US.utf8")
576 (for-each import-cert (find-files certs-dir "\\.pem$"))
577 (mkdir-p (string-append (assoc-ref outputs "out")
579 (mkdir-p (string-append (assoc-ref outputs "jdk")
580 "/jre/lib/security"))
581 (install-file keystore
582 (string-append (assoc-ref outputs "out")
584 (install-file keystore
585 (string-append (assoc-ref outputs "jdk")
586 "/jre/lib/security"))
590 ("alsa-lib" ,alsa-lib)
592 ("autoconf" ,autoconf)
593 ("automake" ,automake)
594 ("coreutils" ,coreutils)
595 ("diffutils" ,diffutils) ;for tests
599 ("pkg-config" ,pkg-config)
607 ("libxslt" ,libxslt) ;for xsltproc
608 ("mit-krb5" ,mit-krb5)
610 ("nss-certs" ,nss-certs)
612 ("libxcomposite" ,libxcomposite)
616 ("libxinerama" ,libxinerama)
617 ("libxrender" ,libxrender)
622 ("procps" ,procps) ;for "free", even though I'm not sure we should use it
626 (uri "https://java.net/downloads/openjdk6/openjdk-6-src-b39-03_may_2016.tar.gz")
629 "1brxbsgwcj4js26y5lk6capc3pvghgjidvv9cavw6z8n7c7aw8af"))))
633 ("fontconfig" ,fontconfig)
634 ("freetype" ,freetype)
636 (home-page "http://icedtea.classpath.org")
637 (synopsis "Java development kit")
639 "The OpenJDK built with the IcedTea build harness.")
640 ;; IcedTea is released under the GPL2 + Classpath exception, which is the
641 ;; same license as both GNU Classpath and OpenJDK.
642 (license license:gpl2+)))
644 (define-public icedtea-7
645 (let* ((version "2.6.6")
646 (drop (lambda (name hash)
650 "http://icedtea.classpath.org/download/drops/"
651 "/icedtea7/" version "/" name ".tar.bz2"))
652 (sha256 (base32 hash))))))
653 (package (inherit icedtea-6)
658 "http://icedtea.wildebeest.org/download/source/icedtea-"
662 "0jjldnig382yqvzzsflilcz897v2lwnw4n57sggdjn318d29g53r"))
663 (modules '((guix build utils)))
665 '(substitute* "Makefile.in"
666 ;; link against libgcj to avoid linker error
668 "-lgcj -o native-ecj")
669 ;; do not leak information about the build host
670 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
671 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
673 `(;; There are many test failures. Some are known to
674 ;; fail upstream, others relate to not having an X
675 ;; server running at test time, yet others are a
676 ;; complete mystery to me.
678 ;; hotspot: passed: 241; failed: 45; error: 2
679 ;; langtools: passed: 1,934; failed: 26
682 ;; Apparently, the C locale is needed for some of the tests.
684 ,@(substitute-keyword-arguments (package-arguments icedtea-6)
689 ((#:configure-flags flags)
690 ;; TODO: package pcsc and sctp, and add to inputs
691 `(append '("--disable-system-pcsc"
692 "--disable-system-sctp")
695 `(modify-phases ,phases
697 (lambda* (#:key source inputs #:allow-other-keys)
698 (let ((target (string-append "icedtea-" ,version))
699 (unpack (lambda* (name #:optional dir)
701 (string-drop-right name 5))))
703 (zero? (system* "tar" "xvf"
704 (assoc-ref inputs name)
706 "--strip-components=1"))))))
709 (zero? (system* "tar" "xvf" source
710 "-C" target "--strip-components=1"))
712 (unpack "openjdk-src" "openjdk.src")
713 (with-directory-excursion "openjdk.src"
715 (filter (cut string-suffix? "-drop" <>)
721 'set-additional-paths
722 (lambda* (#:key inputs #:allow-other-keys)
723 (let (;; Get target-specific include directory so that
724 ;; libgcj-config.h is found when compiling hotspot.
725 (gcjinclude (let* ((port (open-input-pipe "gcj -print-file-name=include"))
726 (str (read-line port)))
729 (substitute* "openjdk.src/jdk/make/common/shared/Sanity.gmk"
730 (("ALSA_INCLUDE=/usr/include/alsa/version.h")
731 (string-append "ALSA_INCLUDE="
732 (assoc-ref inputs "alsa-lib")
733 "/include/alsa/version.h")))
736 (string-append gcjinclude ":"
737 (assoc-ref inputs "libxcomposite")
738 "/include/X11/extensions" ":"
739 (assoc-ref inputs "libxrender")
740 "/include/X11/extensions" ":"
741 (assoc-ref inputs "libxtst")
742 "/include/X11/extensions" ":"
743 (assoc-ref inputs "libxinerama")
744 "/include/X11/extensions" ":"
745 (or (getenv "CPATH") "")))
746 (setenv "ALT_OBJCOPY" (which "objcopy"))
747 (setenv "ALT_CUPS_HEADERS_PATH"
748 (string-append (assoc-ref inputs "cups")
750 (setenv "ALT_FREETYPE_HEADERS_PATH"
751 (string-append (assoc-ref inputs "freetype")
753 (setenv "ALT_FREETYPE_LIB_PATH"
754 (string-append (assoc-ref inputs "freetype")
757 'unpack 'fix-x11-extension-include-path
758 (lambda* (#:key inputs #:allow-other-keys)
759 (substitute* "openjdk.src/jdk/make/sun/awt/mawt.gmk"
760 (((string-append "\\$\\(firstword \\$\\(wildcard "
761 "\\$\\(OPENWIN_HOME\\)"
762 "/include/X11/extensions\\).*$"))
763 (string-append (assoc-ref inputs "libxrender")
764 "/include/X11/extensions"
765 " -I" (assoc-ref inputs "libxtst")
766 "/include/X11/extensions"
767 " -I" (assoc-ref inputs "libxinerama")
768 "/include/X11/extensions"))
769 (("\\$\\(wildcard /usr/include/X11/extensions\\)\\)") ""))
774 ;; Fix PATH in test environment
775 (substitute* "test/jtreg/com/sun/javatest/regtest/Main.java"
776 (("PATH=/bin:/usr/bin")
777 (string-append "PATH=" (getenv "PATH"))))
778 (substitute* "test/jtreg/com/sun/javatest/util/SysEnv.java"
779 (("/usr/bin/env") (which "env")))
780 (substitute* "openjdk.src/hotspot/test/test_env.sh"
781 (("/bin/rm") (which "rm"))
782 (("/bin/cp") (which "cp"))
783 (("/bin/mv") (which "mv")))
785 (delete 'patch-patches))))))
789 "1wxd5kbsmd4gdiz78iq7pq9hp0l6m946pd1pvaj750lkrgk17y14"))
792 "0bba7drdpbggzgn7cnqv10myxa3bygaq2hkclgrmsijhl6bnr26f"))
795 "0c1d4yjaxzh9fi9bx50yi2psb9f475bfivivf6c31smgaihb97k7"))
798 "0662wzws45jwzwfc4pgizxdywz737vflkj9w3hw1xlgljs017bzr"))
801 "17qaf5mdijsn6jzyxv7rgn9g5mazkva6p8lcy7zq06yvfb595ahv"))
804 "1wv34cyba1f4wynjkwf765agf4ifc04717ac7b3bpiagggp2rfsl"))
807 "1hhd5q2g7mnw3pqqv72labki5zv09vgc3hp3xig4x8r4yzzg9s54"))
808 ,@(fold alist-delete (package-native-inputs icedtea-6)
811 `(("libxcomposite" ,libxcomposite)
812 ,@(package-inputs icedtea-6))))))
814 (define-public icedtea-8
815 (let* ((version "3.0.1")
816 (drop (lambda (name hash)
820 "http://icedtea.classpath.org/download/drops/"
821 "/icedtea8/" version "/" name ".tar.xz"))
822 (sha256 (base32 hash))))))
823 (package (inherit icedtea-7)
828 "http://icedtea.wildebeest.org/download/source/icedtea-"
832 "1wislw090zx955rf9sppimdzqf044mpj96xp54vljv6yw46y6v1l"))
833 (modules '((guix build utils)))
835 '(substitute* "Makefile.am"
836 ;; do not leak information about the build host
837 (("DISTRIBUTION_ID=\"\\$\\(DIST_ID\\)\"")
838 "DISTRIBUTION_ID=\"\\\"guix\\\"\"")))))
840 (substitute-keyword-arguments (package-arguments icedtea-7)
841 ((#:configure-flags flags)
842 `(let ((jdk (assoc-ref %build-inputs "jdk")))
843 `(;;"--disable-bootstrap"
846 "--disable-downloading"
847 "--disable-tests" ;they are run in the check phase instead
848 "--with-openjdk-src-dir=./openjdk.src"
849 ,(string-append "--with-jdk-home=" jdk))))
851 `(modify-phases ,phases
852 (delete 'fix-x11-extension-include-path)
853 (delete 'patch-paths)
854 (delete 'set-additional-paths)
855 (delete 'patch-patches)
856 ;; FIXME: This phase is needed but fails with this version of
858 (delete 'install-keystore)
860 (lambda* (#:key outputs #:allow-other-keys)
861 (let ((doc (string-append (assoc-ref outputs "doc")
862 "/share/doc/icedtea"))
863 (jre (assoc-ref outputs "out"))
864 (jdk (assoc-ref outputs "jdk")))
865 (copy-recursively "openjdk.build/docs" doc)
866 (copy-recursively "openjdk.build/images/j2re-image" jre)
867 (copy-recursively "openjdk.build/images/j2sdk-image" jdk)
870 `(("jdk" ,icedtea-7 "jdk")
873 "1141wfz6vz889f5naj7zdbyw42ibw0ixvkd808lfcrwxlgznyxlb"))
876 "0l3fmfw88hf8709z033az1x6wzmcb0jnakj2br1r721zw01i0da2"))
879 "1i1pvyrdkk3w8vcnk6kfcbsjkfpbbrcywiypdl39bf2ishixbaf0"))
882 "0f1kglci65zsfy8ygw5w2zza7v1280znihvls4kraz06dgsc2y73"))
885 "1pcwb1kjd1ph4jbv07icgk0fb8jqnck2y24qjfd7dzg7gm45c1am"))
888 "1jjil9s244wp0blj1qkzk7sy7y1jrxb4wq18c1rj2q2pa88n00i6"))
891 "1pl0cz1gja6z5zbywni1x1pj4qkh745fpj55fcmj4lpfj2p98my1"))
894 "1p0ynm2caraq1sal38qrrf42yah7j14c9vfwdv6h5h4rliahs177"))
895 ,@(fold alist-delete (package-native-inputs icedtea-7)
896 '("gcj" "openjdk-src" "corba-drop" "jaxp-drop" "jaxws-drop"
897 "jdk-drop" "langtools-drop" "hotspot-drop")))))))
899 (define-public icedtea icedtea-7)
901 (define-public java-xz
907 (uri (string-append "http://tukaani.org/xz/xz-java-" version ".zip"))
910 "0x6vn9dp9kxk83x2fp3394n95dk8fx9yg8jns9371iqsn0vy8ih1"))))
911 (build-system ant-build-system)
913 `(#:tests? #f ; There are no tests to run.
914 #:jar-name ,(string-append "xz-" version ".jar")
916 (modify-phases %standard-phases
917 ;; The unpack phase enters the "maven" directory by accident.
918 (add-after 'unpack 'chdir
919 (lambda _ (chdir "..") #t)))))
922 (home-page "http://tukaani.org/xz/java.html")
923 (synopsis "Implementation of XZ data compression in pure Java")
924 (description "This library aims to be a complete implementation of XZ data
925 compression in pure Java. Single-threaded streamed compression and
926 decompression and random access decompression have been fully implemented.")
927 (license license:public-domain)))
929 ;; java-hamcrest-core uses qdox version 1.12. We package this version instead
930 ;; of the latest release.
931 (define-public java-qdox-1.12
937 (uri (string-append "http://central.maven.org/maven2/"
938 "com/thoughtworks/qdox/qdox/" version
939 "/qdox-" version "-sources.jar"))
942 "0hlfbqq2avf5s26wxkksqmkdyk6zp9ggqn37c468m96mjv0n9xfl"))))
943 (build-system ant-build-system)
945 `(;; Tests require junit
947 #:jar-name "qdox.jar"
949 (modify-phases %standard-phases
951 (lambda* (#:key source #:allow-other-keys)
953 (with-directory-excursion "src"
954 (zero? (system* "jar" "-xf" source)))))
955 ;; At this point we don't have junit, so we must remove the API
957 (add-after 'unpack 'delete-tests
959 (delete-file-recursively "src/com/thoughtworks/qdox/junit")
961 (home-page "http://qdox.codehaus.org/")
962 (synopsis "Parse definitions from Java source files")
964 "QDox is a high speed, small footprint parser for extracting
965 class/interface/method definitions from source files complete with JavaDoc
966 @code{@@tags}. It is designed to be used by active code generators or
967 documentation tools.")
968 (license license:asl2.0)))
970 (define-public java-jarjar
977 "https://storage.googleapis.com/google-code-archive-downloads/v2/"
978 "code.google.com/jarjar/jarjar-src-" version ".zip"))
981 "1v8irhni9cndcw1l1wxqgry013s2kpj0qqn57lj2ji28xjq8ndjl"))))
982 (build-system ant-build-system)
984 `(;; Tests require junit, which ultimately depends on this package.
988 (modify-phases %standard-phases
990 (lambda* (#:key outputs #:allow-other-keys)
991 (let ((target (string-append (assoc-ref outputs "out")
993 (install-file (string-append "dist/jarjar-" ,version ".jar")
998 (home-page "https://code.google.com/archive/p/jarjar/")
999 (synopsis "Repackage Java libraries")
1001 "Jar Jar Links is a utility that makes it easy to repackage Java
1002 libraries and embed them into your own distribution. Jar Jar Links includes
1003 an Ant task that extends the built-in @code{jar} task.")
1004 (license license:asl2.0)))
1006 (define-public java-hamcrest-core
1008 (name "java-hamcrest-core")
1012 (uri (string-append "https://hamcrest.googlecode.com/files/"
1013 "hamcrest-" version ".tgz"))
1016 "1hi0jv0zrgsf4l25aizxrgvxpsrmdklsmvw0jzwz7zv9s108whn6"))
1017 (modules '((guix build utils)))
1020 ;; Delete bundled jar archives.
1021 (for-each delete-file (find-files "." "\\.jar$"))
1023 (build-system ant-build-system)
1025 `(#:tests? #f ; Tests require junit
1026 #:make-flags (list (string-append "-Dversion=" ,version))
1027 #:build-target "core"
1029 (modify-phases %standard-phases
1030 ;; Disable unit tests, because they require junit, which requires
1031 ;; hamcrest-core. We also give a fixed value to the "Built-Date"
1032 ;; attribute from the manifest for reproducibility.
1033 (add-before 'configure 'patch-build.xml
1035 (substitute* "build.xml"
1036 (("unit-test, ") "")
1037 (("\\$\\{build.timestamp\\}") "guix"))
1039 ;; Java's "getMethods()" returns methods in an unpredictable order.
1040 ;; To make the output of the generated code deterministic we must
1041 ;; sort the array of methods.
1042 (add-after 'unpack 'make-method-order-deterministic
1044 (substitute* "hamcrest-generator/src/main/java/org/hamcrest/generator/ReflectiveFactoryReader.java"
1045 (("import java\\.util\\.Iterator;" line)
1046 (string-append line "\n"
1047 "import java.util.Arrays; import java.util.Comparator;"))
1048 (("allMethods = cls\\.getMethods\\(\\);" line)
1049 (string-append "_" line
1051 private Method[] getSortedMethods() {
1052 Arrays.sort(_allMethods, new Comparator<Method>() {
1054 public int compare(Method a, Method b) {
1055 return a.toString().compareTo(b.toString());
1061 private Method[] allMethods = getSortedMethods();")))))
1062 (add-before 'build 'do-not-use-bundled-qdox
1063 (lambda* (#:key inputs #:allow-other-keys)
1064 (substitute* "build.xml"
1065 (("lib/generator/qdox-1.12.jar")
1066 (string-append (assoc-ref inputs "java-qdox-1.12")
1067 "/share/java/qdox.jar")))
1070 (lambda* (#:key outputs #:allow-other-keys)
1071 (install-file (string-append "build/hamcrest-core-"
1073 (string-append (assoc-ref outputs "out")
1074 "/share/java")))))))
1076 `(("java-qdox-1.12" ,java-qdox-1.12)
1077 ("java-jarjar" ,java-jarjar)))
1078 (home-page "http://hamcrest.org/")
1079 (synopsis "Library of matchers for building test expressions")
1081 "This package provides a library of matcher objects (also known as
1082 constraints or predicates) allowing @code{match} rules to be defined
1083 declaratively, to be used in other frameworks. Typical scenarios include
1084 testing frameworks, mocking libraries and UI validation rules.")
1085 (license license:bsd-2)))
1087 (define-public java-junit
1093 (uri (string-append "https://github.com/junit-team/junit/"
1094 "archive/r" version ".tar.gz"))
1095 (file-name (string-append name "-" version ".tar.gz"))
1098 "090dn5v1vs0b3acyaqc0gjf6p8lmd2h24wfzsbq7sly6b214anws"))
1099 (modules '((guix build utils)))
1102 ;; Delete bundled jar archives.
1103 (delete-file-recursively "lib")
1105 (build-system ant-build-system)
1107 `(#:tests? #f ; no tests
1108 #:jar-name "junit.jar"))
1110 `(("java-hamcrest-core" ,java-hamcrest-core)))
1111 (home-page "http://junit.org/")
1112 (synopsis "Test framework for Java")
1114 "JUnit is a simple framework to write repeatable tests for Java projects.
1115 JUnit provides assertions for testing expected results, test fixtures for
1116 sharing common test data, and test runners for running tests.")
1117 (license license:epl1.0)))