gnu: java-snappy@1.0: Don't use unstable tarball.
[jackhill/guix/guix.git] / gnu / packages / java-compression.scm
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>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
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.
14 ;;;
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.
19 ;;;
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/>.
22
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))
35
36 (define-public java-snappy
37 (package
38 (name "java-snappy")
39 (version "1.1.7.3")
40 (source
41 (origin
42 (method git-fetch)
43 (uri (git-reference
44 (url "https://github.com/xerial/snappy-java")
45 (commit version)))
46 (sha256
47 (base32 "07c145w1kv8g7dbwpy5xss142il7zr0qq78p2ih76azgl97n5cba"))
48 (file-name (git-file-name name version))))
49 (build-system ant-build-system)
50 (arguments
51 `(#:jar-name "snappy.jar"
52 #:source-dir "src/main/java"
53 #:phases
54 (modify-phases %standard-phases
55 (add-after 'unpack 'make-git-checkout-writable
56 (lambda _
57 (for-each make-file-writable (find-files "."))
58 #t))
59 (add-before 'build 'remove-binaries
60 (lambda _
61 (delete-file "lib/org/xerial/snappy/OSInfo.class")
62 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
63 #t))
64 (add-before 'build 'build-jni
65 (lambda _
66 ;; Rebuild one of the binaries we removed earlier
67 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
68 "-d" "lib")
69 ;; Link to the dynamic bitshuffle and snappy, not the static ones
70 (substitute* "Makefile.common"
71 (("-shared")
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\\) ")
77 "")
78 ((": \\$\\(SNAPPY_GIT_UNPACKED\\)")
79 ":")
80 (("\\$\\(BITSHUFFLE_UNPACKED\\) ")
81 "")
82 ((": \\$\\(SNAPPY_SOURCE_CONFIGURED\\)") ":")
83 ;; What we actually want to build
84 (("SNAPPY_OBJ:=.*")
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
98 (lambda _
99 (copy-recursively "src/main/resources/org/xerial/snappy/native"
100 "build/classes/org/xerial/snappy/native")
101 #t))
102 (add-before 'check 'fix-failing
103 (lambda _
104 (with-directory-excursion "src/test/java/org/xerial/snappy"
105 ;; This package assumes maven build, which puts results in "target".
106 ;; We put them in "build" instead, so fix that.
107 (substitute* "SnappyLoaderTest.java"
108 (("target/classes") "build/classes"))
109 ;; This requires Hadoop, which is not in Guix yet.
110 (delete-file "SnappyHadoopCompatibleOutputStreamTest.java"))
111 #t)))))
112 (inputs
113 `(("osgi-framework" ,java-osgi-framework)))
114 (propagated-inputs
115 `(("bitshuffle" ,bitshuffle-for-snappy)
116 ("snappy" ,snappy)))
117 (native-inputs
118 `(("junit" ,java-junit)
119 ("hamcrest" ,java-hamcrest-core)
120 ("xerial-core" ,java-xerial-core)
121 ("classworlds" ,java-plexus-classworlds)
122 ("commons-lang" ,java-commons-lang)
123 ("commons-io" ,java-commons-io)
124 ("perl" ,perl)))
125 (home-page "https://github.com/xerial/snappy-java")
126 (synopsis "Compression/decompression algorithm in Java")
127 (description "Snappy-java is a Java port of snappy, a fast C++
128 compressor/decompressor.")
129 (license license:asl2.0)))
130
131 (define-public java-snappy-1
132 (package
133 (inherit java-snappy)
134 (name "java-snappy")
135 (version "1.0.3-rc3")
136 (source
137 (origin
138 (method git-fetch)
139 (uri (git-reference
140 (url (string-append "https://github.com/xerial/snappy-java"))
141 (commit (string-append "snappy-java-" version))))
142 (sha256
143 (base32 "0gbg3xmhniyh5p6w5zqj16fr15fa8j4raswd8pj00l4ixf5qa6m4"))
144 (file-name (git-file-name name version))))
145 (arguments
146 `(#:jar-name "snappy.jar"
147 #:source-dir "src/main/java"
148 #:phases
149 (modify-phases %standard-phases
150 (add-before 'build 'remove-binaries
151 (lambda _
152 (delete-file "lib/org/xerial/snappy/OSInfo.class")
153 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
154 #t))
155 (add-before 'build 'build-jni
156 (lambda _
157 ;; Rebuild one of the binaries we removed earlier
158 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
159 "-d" "lib")
160 ;; Link to the dynamic snappy, not the static ones
161 (substitute* "Makefile.common"
162 (("-shared") "-shared -lsnappy"))
163 (substitute* "Makefile"
164 ;; Don't download the sources here.
165 (("\\$\\(SNAPPY_UNPACKED\\) ") "")
166 ((": \\$\\(SNAPPY_UNPACKED\\) ") ":")
167 ;; What we actually want to build
168 (("SNAPPY_OBJ:=.*")
169 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, SnappyNative.o)\n")
170 ;; Since we removed the directory structure in "native" during
171 ;; the previous phase, we need to recreate it.
172 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
173 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
174 ;; Finally we can run the Makefile to build the dynamic library.
175 (invoke "make" "native")))
176 ;; Once we have built the shared library, we need to place it in the
177 ;; "build" directory so it can be added to the jar file.
178 (add-after 'build-jni 'copy-jni
179 (lambda _
180 (copy-recursively "src/main/resources/org/xerial/snappy/native"
181 "build/classes/org/xerial/snappy/native")
182 #t))
183 (add-before 'check 'fix-tests
184 (lambda _
185 (mkdir-p "src/test/resources/org/xerial/snappy/")
186 (copy-recursively "src/test/java/org/xerial/snappy/testdata"
187 "src/test/resources/org/xerial/snappy/testdata")
188 (install-file "src/test/java/org/xerial/snappy/alice29.txt"
189 "src/test/resources/org/xerial/snappy/")
190 #t)))))))
191
192 (define-public java-iq80-snappy
193 (package
194 (name "java-iq80-snappy")
195 (version "0.4")
196 (source (origin
197 (method url-fetch)
198 (uri (string-append "https://github.com/dain/snappy/archive/snappy-"
199 version ".tar.gz"))
200 (sha256
201 (base32
202 "0rb3zhci7w9wzd65lfnk7p3ip0n6gb58a9qpx8n7r0231gahyamf"))))
203 (build-system ant-build-system)
204 (arguments
205 `(#:jar-name "iq80-snappy.jar"
206 #:source-dir "src/main/java"
207 #:test-dir "src/test"
208 #:jdk ,icedtea-8
209 #:phases
210 (modify-phases %standard-phases
211 (replace 'check
212 (lambda _
213 (define (test class)
214 (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
215 ":build/classes"
216 ":build/test-classes")
217 "-Dtest.resources.dir=src/test/resources"
218 "org.testng.TestNG" "-testclass"
219 class))
220 (invoke "ant" "compile-tests")
221 (test "org.iq80.snappy.SnappyFramedStreamTest")
222 (test "org.iq80.snappy.SnappyStreamTest")
223 #t))
224 (add-before 'build 'remove-hadoop-dependency
225 (lambda _
226 ;; We don't have hadoop
227 (delete-file "src/main/java/org/iq80/snappy/HadoopSnappyCodec.java")
228 (delete-file "src/test/java/org/iq80/snappy/TestHadoopSnappyCodec.java")
229 #t)))))
230 (home-page "https://github.com/dain/snappy")
231 (native-inputs
232 `(("guava" ,java-guava)
233 ("java-snappy" ,java-snappy)
234 ("hamcrest" ,java-hamcrest-core)
235 ("testng" ,java-testng)))
236 (synopsis "Java port of the Snappy (de)compressor")
237 (description
238 "Iq80-snappy is a port of the Snappy compressor and decompressor rewritten
239 in pure Java. This compression code produces a byte-for-byte exact copy of the
240 output created by the original C++ code, and is extremely fast.")
241 (license license:asl2.0)))
242
243 (define-public java-jbzip2
244 (package
245 (name "java-jbzip2")
246 (version "0.9.1")
247 (source (origin
248 (method url-fetch)
249 (uri (string-append "https://storage.googleapis.com/"
250 "google-code-archive-source/v2/"
251 "code.google.com/jbzip2/"
252 "source-archive.zip"))
253 (file-name (string-append name "-" version ".zip"))
254 (sha256
255 (base32
256 "0ncmhlqmrfmj96nqf6p77b9ws35lcfsvpfxzwxi2asissc83z1l3"))))
257 (build-system ant-build-system)
258 (native-inputs
259 `(("unzip" ,unzip)
260 ("java-junit" ,java-junit)))
261 (arguments
262 `(#:tests? #f ; no tests
263 #:jar-name "jbzip2.jar"
264 #:source-dir "tags/release-0.9.1/src"
265 #:phases
266 (modify-phases %standard-phases
267 (add-after 'unpack 'fix-encoding-problems
268 (lambda _
269 ;; Some of the files we're patching are
270 ;; ISO-8859-1-encoded, so choose it as the default
271 ;; encoding so the byte encoding is preserved.
272 (with-fluids ((%default-port-encoding #f))
273 (substitute* "tags/release-0.9.1/src/org/itadaki/bzip2/HuffmanAllocator.java"
274 (("Milidi.") "Milidiu")))
275 #t)))))
276 (home-page "https://code.google.com/archive/p/jbzip2/")
277 (synopsis "Java bzip2 compression/decompression library")
278 (description "Jbzip2 is a Java bzip2 compression/decompression library.
279 It can be used as a replacement for the Apache @code{CBZip2InputStream} /
280 @code{CBZip2OutputStream} classes.")
281 (license license:expat)))
282
283 (define-public java-tukaani-xz
284 (package
285 (name "java-tukaani-xz")
286 (version "1.6")
287 (source (origin
288 (method url-fetch)
289 (uri (string-append "https://tukaani.org/xz/xz-java-" version ".zip"))
290 (sha256
291 (base32
292 "1z3p1ri1gvl07inxn0agx44ck8n7wrzfmvkz8nbq3njn8r9wba8x"))))
293 (build-system ant-build-system)
294 (arguments
295 `(#:tests? #f; no tests
296 #:phases
297 (modify-phases %standard-phases
298 (add-after 'unpack 'chdir
299 (lambda _
300 ;; Our build system enters the first directory in the archive, but
301 ;; the package is not contained in a subdirectory
302 (chdir "..")
303 #t))
304 (replace 'install
305 (lambda* (#:key outputs #:allow-other-keys)
306 ;; Do we want to install *Demo.jar?
307 (install-file "build/jar/xz.jar"
308 (string-append
309 (assoc-ref outputs "out")
310 "/share/java/xz.jar"))
311 #t)))))
312 (native-inputs
313 `(("unzip" ,unzip)))
314 (home-page "https://tukaani.org")
315 (synopsis "XZ in Java")
316 (description "Tukaani-xz is an implementation of xz compression/decompression
317 algorithms in Java.")
318 (license license:public-domain)))