projects/guix·blob version-0.12.0 · refs

1296 lines · 58.9 KiB

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