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