1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2017, 2018 Julien Lepiller <julien@lepiller.eu>
4 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
5 ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages java-compression)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix utils)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix build-system ant)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages java)
33 #:use-module (gnu packages perl)
34 #:use-module (gnu packages python-compression))
36 (define-public java-snappy
44 (url "https://github.com/xerial/snappy-java")
47 (base32 "0894zyasrmbi268d1ky9db16wrnc6x8b9ilq0b5paaxi2pwgjlrp"))
48 (file-name (git-file-name name version))))
49 (build-system ant-build-system)
51 `(#:jar-name "snappy.jar"
52 #:source-dir "src/main/java"
54 (modify-phases %standard-phases
55 (add-after 'unpack 'make-git-checkout-writable
57 (for-each make-file-writable (find-files "."))
59 (add-before 'build 'remove-binaries
61 (delete-file "lib/org/xerial/snappy/OSInfo.class")
62 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
64 (add-before 'build 'build-jni
66 ;; Rebuild one of the binaries we removed earlier
67 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
69 ;; Link to the dynamic bitshuffle and snappy, not the static ones
70 (substitute* "Makefile.common"
72 "-shared -lbitshuffle -lsnappy"))
73 (substitute* "Makefile"
74 ;; Don't try to use git, don't download bitshuffle source
75 ;; and don't build it.
76 (("\\$\\(SNAPPY_GIT_UNPACKED\\) ")
78 ((": \\$\\(SNAPPY_GIT_UNPACKED\\)")
80 (("\\$\\(BITSHUFFLE_UNPACKED\\) ")
82 ((": \\$\\(SNAPPY_SOURCE_CONFIGURED\\)") ":")
83 ;; What we actually want to build
85 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, \
86 SnappyNative.o BitShuffleNative.o)\n")
87 ;; Since we removed the directory structure in "native" during
88 ;; the previous phase, we need to recreate it.
89 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
90 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
91 ;; Finally we can run the Makefile to build the dynamic library.
92 ;; Use the -nocmake target to avoid a dependency on cmake,
93 ;; which in turn requires the "git_unpacked" directory.
94 (invoke "make" "native-nocmake")))
95 ;; Once we have built the shared library, we need to place it in the
96 ;; "build" directory so it can be added to the jar file.
97 (add-after 'build-jni 'copy-jni
99 (copy-recursively "src/main/resources/org/xerial/snappy/native"
100 "build/classes/org/xerial/snappy/native")
102 (add-before 'build 'set-test-memory-size
104 (substitute* "build.xml"
105 (("<junit printsummary=") "<junit maxmemory=\"2G\" printsummary="))
107 (add-before 'check 'fix-failing
109 (with-directory-excursion "src/test/java/org/xerial/snappy"
110 ;; This package assumes maven build, which puts results in "target".
111 ;; We put them in "build" instead, so fix that.
112 (substitute* "SnappyLoaderTest.java"
113 (("target/classes") "build/classes"))
114 ;; This requires Hadoop, which is not in Guix yet.
115 (delete-file "SnappyHadoopCompatibleOutputStreamTest.java"))
118 `(("osgi-framework" ,java-osgi-framework)))
120 `(("bitshuffle" ,bitshuffle-for-snappy)
123 `(("junit" ,java-junit)
124 ("hamcrest" ,java-hamcrest-core)
125 ("xerial-core" ,java-xerial-core)
126 ("classworlds" ,java-plexus-classworlds)
127 ("commons-lang" ,java-commons-lang)
128 ("commons-io" ,java-commons-io)
130 (home-page "https://github.com/xerial/snappy-java")
131 (synopsis "Compression/decompression algorithm in Java")
132 (description "Snappy-java is a Java port of snappy, a fast C++
133 compressor/decompressor.")
134 (license license:asl2.0)))
136 (define-public java-snappy-1
138 (inherit java-snappy)
140 (version "1.0.3-rc3")
145 (url (string-append "https://github.com/xerial/snappy-java"))
146 (commit (string-append "snappy-java-" version))))
148 (base32 "0gbg3xmhniyh5p6w5zqj16fr15fa8j4raswd8pj00l4ixf5qa6m4"))
149 (file-name (git-file-name name version))))
151 `(#:jar-name "snappy.jar"
152 #:source-dir "src/main/java"
154 (modify-phases %standard-phases
155 (add-before 'build 'remove-binaries
157 (delete-file "lib/org/xerial/snappy/OSInfo.class")
158 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
160 (add-before 'build 'build-jni
162 ;; Rebuild one of the binaries we removed earlier
163 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
165 ;; Link to the dynamic snappy, not the static ones
166 (substitute* "Makefile.common"
167 (("-shared") "-shared -lsnappy"))
168 (substitute* "Makefile"
169 ;; Don't download the sources here.
170 (("\\$\\(SNAPPY_UNPACKED\\) ") "")
171 ((": \\$\\(SNAPPY_UNPACKED\\) ") ":")
172 ;; What we actually want to build
174 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, SnappyNative.o)\n")
175 ;; Since we removed the directory structure in "native" during
176 ;; the previous phase, we need to recreate it.
177 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
178 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
179 ;; Finally we can run the Makefile to build the dynamic library.
180 (invoke "make" "native")))
181 ;; Once we have built the shared library, we need to place it in the
182 ;; "build" directory so it can be added to the jar file.
183 (add-after 'build-jni 'copy-jni
185 (copy-recursively "src/main/resources/org/xerial/snappy/native"
186 "build/classes/org/xerial/snappy/native")
188 (add-before 'check 'fix-tests
190 (mkdir-p "src/test/resources/org/xerial/snappy/")
191 (copy-recursively "src/test/java/org/xerial/snappy/testdata"
192 "src/test/resources/org/xerial/snappy/testdata")
193 (install-file "src/test/java/org/xerial/snappy/alice29.txt"
194 "src/test/resources/org/xerial/snappy/")
197 (define-public java-iq80-snappy
199 (name "java-iq80-snappy")
205 (url "https://github.com/dain/snappy")
206 (commit (string-append "snappy-" version))))
208 (base32 "1mswh207065rdzbxk6rxaqlxhbg1ngxa0vjc20knsn31kqbq1bcz"))
209 (file-name (git-file-name name version))))
210 (build-system ant-build-system)
212 `(#:jar-name "iq80-snappy.jar"
213 #:source-dir "src/main/java"
214 #:test-dir "src/test"
216 (modify-phases %standard-phases
220 (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
222 ":build/test-classes")
223 "-Dtest.resources.dir=src/test/resources"
224 "org.testng.TestNG" "-testclass"
226 (invoke "ant" "compile-tests")
227 (test "org.iq80.snappy.SnappyFramedStreamTest")
228 (test "org.iq80.snappy.SnappyStreamTest")
230 (add-before 'build 'remove-hadoop-dependency
232 ;; We don't have hadoop
233 (delete-file "src/main/java/org/iq80/snappy/HadoopSnappyCodec.java")
234 (delete-file "src/test/java/org/iq80/snappy/TestHadoopSnappyCodec.java")
236 (replace 'install (install-from-pom "pom.xml")))))
237 (home-page "https://github.com/dain/snappy")
239 `(("java-guava" ,java-guava)
240 ("java-snappy" ,java-snappy)
241 ("java-testng" ,java-testng)))
242 (synopsis "Java port of the Snappy (de)compressor")
244 "Iq80-snappy is a port of the Snappy compressor and decompressor rewritten
245 in pure Java. This compression code produces a byte-for-byte exact copy of the
246 output created by the original C++ code, and is extremely fast.")
247 (license license:asl2.0)))
249 (define-public java-jbzip2
255 (uri (string-append "https://storage.googleapis.com/"
256 "google-code-archive-source/v2/"
257 "code.google.com/jbzip2/"
258 "source-archive.zip"))
259 (file-name (string-append name "-" version ".zip"))
262 "0ncmhlqmrfmj96nqf6p77b9ws35lcfsvpfxzwxi2asissc83z1l3"))))
263 (build-system ant-build-system)
266 ("java-junit" ,java-junit)))
268 `(#:tests? #f ; no tests
269 #:jar-name "jbzip2.jar"
270 #:source-dir "tags/release-0.9.1/src"
272 (modify-phases %standard-phases
273 (add-after 'unpack 'fix-encoding-problems
275 ;; Some of the files we're patching are
276 ;; ISO-8859-1-encoded, so choose it as the default
277 ;; encoding so the byte encoding is preserved.
278 (with-fluids ((%default-port-encoding #f))
279 (substitute* "tags/release-0.9.1/src/org/itadaki/bzip2/HuffmanAllocator.java"
280 (("Milidi.") "Milidiu")))
282 (home-page "https://code.google.com/archive/p/jbzip2/")
283 (synopsis "Java bzip2 compression/decompression library")
284 (description "Jbzip2 is a Java bzip2 compression/decompression library.
285 It can be used as a replacement for the Apache @code{CBZip2InputStream} /
286 @code{CBZip2OutputStream} classes.")
287 (license license:expat)))
289 (define-public java-xz
295 (uri (string-append "https://tukaani.org/xz/xz-java-" version ".zip"))
298 "1z3p1ri1gvl07inxn0agx44ck8n7wrzfmvkz8nbq3njn8r9wba8x"))))
299 (build-system ant-build-system)
301 `(#:tests? #f; no tests
303 (modify-phases %standard-phases
304 (add-after 'unpack 'chdir
306 ;; Our build system enters the first directory in the archive, but
307 ;; the package is not contained in a subdirectory
310 (add-before 'install 'generate-pom
312 (copy-file "maven/pom_template.xml" "pom.xml")
313 (substitute* "pom.xml"
314 (("@VERSION@") ,version)
315 (("@TITLE@") "XZ data compression")
316 (("@HOMEPAGE@") "http://tukaani.org/xz/java.html"))
318 (add-before 'install 'rename-jar
320 (rename-file "build/jar/xz.jar"
321 (string-append "build/jar/xz-" ,version ".jar"))
324 (install-from-pom "pom.xml")))))
327 (home-page "https://tukaani.org")
328 (synopsis "XZ in Java")
329 (description "Tukaani-xz is an implementation of xz compression/decompression
330 algorithms in Java.")
331 (license license:public-domain)))