gnu: python-deepmerge: Use pyproject-build-system.
[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 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages java-compression)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix utils)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system ant)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages java)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages python-compression))
36
37 (define-public java-snappy
38 (package
39 (name "java-snappy")
40 (version "1.1.7.5")
41 (source
42 (origin
43 (method git-fetch)
44 (uri (git-reference
45 (url "https://github.com/xerial/snappy-java")
46 (commit version)))
47 (sha256
48 (base32 "0894zyasrmbi268d1ky9db16wrnc6x8b9ilq0b5paaxi2pwgjlrp"))
49 (file-name (git-file-name name version))))
50 (build-system ant-build-system)
51 (arguments
52 `(#:jar-name "snappy.jar"
53 #:source-dir "src/main/java"
54 #:phases
55 (modify-phases %standard-phases
56 (add-after 'unpack 'make-git-checkout-writable
57 (lambda _
58 (for-each make-file-writable (find-files "."))
59 #t))
60 (add-before 'build 'remove-binaries
61 (lambda _
62 (delete-file "lib/org/xerial/snappy/OSInfo.class")
63 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
64 #t))
65 (add-before 'build 'build-jni
66 (lambda _
67 ;; Rebuild one of the binaries we removed earlier
68 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
69 "-d" "lib")
70 ;; Link to the dynamic bitshuffle and snappy, not the static ones
71 (substitute* "Makefile.common"
72 (("-shared")
73 "-shared -lbitshuffle -lsnappy"))
74 (substitute* "Makefile"
75 ;; Don't try to use git, don't download bitshuffle source
76 ;; and don't build it.
77 (("\\$\\(SNAPPY_GIT_UNPACKED\\) ")
78 "")
79 ((": \\$\\(SNAPPY_GIT_UNPACKED\\)")
80 ":")
81 (("\\$\\(BITSHUFFLE_UNPACKED\\) ")
82 "")
83 ((": \\$\\(SNAPPY_SOURCE_CONFIGURED\\)") ":")
84 ;; What we actually want to build
85 (("SNAPPY_OBJ:=.*")
86 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, \
87 SnappyNative.o BitShuffleNative.o)\n")
88 ;; Since we removed the directory structure in "native" during
89 ;; the previous phase, we need to recreate it.
90 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
91 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
92 ;; Finally we can run the Makefile to build the dynamic library.
93 ;; Use the -nocmake target to avoid a dependency on cmake,
94 ;; which in turn requires the "git_unpacked" directory.
95 (invoke "make" "native-nocmake")))
96 ;; Once we have built the shared library, we need to place it in the
97 ;; "build" directory so it can be added to the jar file.
98 (add-after 'build-jni 'copy-jni
99 (lambda _
100 (copy-recursively "src/main/resources/org/xerial/snappy/native"
101 "build/classes/org/xerial/snappy/native")
102 #t))
103 (add-before 'build 'set-test-memory-size
104 (lambda _
105 (substitute* "build.xml"
106 (("<junit printsummary=") "<junit maxmemory=\"2G\" printsummary="))
107 #t))
108 (add-before 'check 'fix-failing
109 (lambda _
110 (with-directory-excursion "src/test/java/org/xerial/snappy"
111 ;; This package assumes maven build, which puts results in "target".
112 ;; We put them in "build" instead, so fix that.
113 (substitute* "SnappyLoaderTest.java"
114 (("target/classes") "build/classes"))
115 ;; This requires Hadoop, which is not in Guix yet.
116 (delete-file "SnappyHadoopCompatibleOutputStreamTest.java"))
117 #t)))))
118 (inputs
119 `(("osgi-framework" ,java-osgi-framework)))
120 (propagated-inputs
121 `(("bitshuffle" ,bitshuffle-for-snappy)
122 ("snappy" ,snappy)))
123 (native-inputs
124 `(("junit" ,java-junit)
125 ("hamcrest" ,java-hamcrest-core)
126 ("xerial-core" ,java-xerial-core)
127 ("classworlds" ,java-plexus-classworlds)
128 ("commons-lang" ,java-commons-lang)
129 ("commons-io" ,java-commons-io)
130 ("perl" ,perl)))
131 (home-page "https://github.com/xerial/snappy-java")
132 (synopsis "Compression/decompression algorithm in Java")
133 (description "Snappy-java is a Java port of snappy, a fast C++
134 compressor/decompressor.")
135 (license license:asl2.0)))
136
137 (define-public java-snappy-1
138 (package
139 (inherit java-snappy)
140 (name "java-snappy")
141 (version "1.0.3-rc3")
142 (source
143 (origin
144 (method git-fetch)
145 (uri (git-reference
146 (url (string-append "https://github.com/xerial/snappy-java"))
147 (commit (string-append "snappy-java-" version))))
148 (sha256
149 (base32 "0gbg3xmhniyh5p6w5zqj16fr15fa8j4raswd8pj00l4ixf5qa6m4"))
150 (file-name (git-file-name name version))))
151 (arguments
152 `(#:jar-name "snappy.jar"
153 #:source-dir "src/main/java"
154 #:phases
155 (modify-phases %standard-phases
156 (add-before 'build 'remove-binaries
157 (lambda _
158 (delete-file "lib/org/xerial/snappy/OSInfo.class")
159 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
160 #t))
161 (add-before 'build 'build-jni
162 (lambda _
163 ;; Rebuild one of the binaries we removed earlier
164 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
165 "-d" "lib")
166 ;; Link to the dynamic snappy, not the static ones
167 (substitute* "Makefile.common"
168 (("-shared") "-shared -lsnappy"))
169 (substitute* "Makefile"
170 ;; Don't download the sources here.
171 (("\\$\\(SNAPPY_UNPACKED\\) ") "")
172 ((": \\$\\(SNAPPY_UNPACKED\\) ") ":")
173 ;; What we actually want to build
174 (("SNAPPY_OBJ:=.*")
175 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, SnappyNative.o)\n")
176 ;; Since we removed the directory structure in "native" during
177 ;; the previous phase, we need to recreate it.
178 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
179 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
180 ;; Finally we can run the Makefile to build the dynamic library.
181 (invoke "make" "native")))
182 ;; Once we have built the shared library, we need to place it in the
183 ;; "build" directory so it can be added to the jar file.
184 (add-after 'build-jni 'copy-jni
185 (lambda _
186 (copy-recursively "src/main/resources/org/xerial/snappy/native"
187 "build/classes/org/xerial/snappy/native")
188 #t))
189 (add-before 'check 'fix-tests
190 (lambda _
191 (mkdir-p "src/test/resources/org/xerial/snappy/")
192 (copy-recursively "src/test/java/org/xerial/snappy/testdata"
193 "src/test/resources/org/xerial/snappy/testdata")
194 (install-file "src/test/java/org/xerial/snappy/alice29.txt"
195 "src/test/resources/org/xerial/snappy/")
196 #t)))))))
197
198 (define-public java-iq80-snappy
199 (package
200 (name "java-iq80-snappy")
201 (version "0.4")
202 (source
203 (origin
204 (method git-fetch)
205 (uri (git-reference
206 (url "https://github.com/dain/snappy")
207 (commit (string-append "snappy-" version))))
208 (sha256
209 (base32 "1mswh207065rdzbxk6rxaqlxhbg1ngxa0vjc20knsn31kqbq1bcz"))
210 (file-name (git-file-name name version))))
211 (build-system ant-build-system)
212 (arguments
213 `(#:jar-name "iq80-snappy.jar"
214 #:source-dir "src/main/java"
215 #:test-dir "src/test"
216 #:phases
217 (modify-phases %standard-phases
218 (replace 'check
219 (lambda _
220 (define (test class)
221 (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
222 ":build/classes"
223 ":build/test-classes")
224 "-Dtest.resources.dir=src/test/resources"
225 "org.testng.TestNG" "-testclass"
226 class))
227 (invoke "ant" "compile-tests")
228 (test "org.iq80.snappy.SnappyFramedStreamTest")
229 (test "org.iq80.snappy.SnappyStreamTest")
230 #t))
231 (add-before 'build 'remove-hadoop-dependency
232 (lambda _
233 ;; We don't have hadoop
234 (delete-file "src/main/java/org/iq80/snappy/HadoopSnappyCodec.java")
235 (delete-file "src/test/java/org/iq80/snappy/TestHadoopSnappyCodec.java")
236 #t))
237 (replace 'install (install-from-pom "pom.xml")))))
238 (home-page "https://github.com/dain/snappy")
239 (native-inputs
240 (list java-guava java-snappy java-testng))
241 (synopsis "Java port of the Snappy (de)compressor")
242 (description
243 "Iq80-snappy is a port of the Snappy compressor and decompressor rewritten
244 in pure Java. This compression code produces a byte-for-byte exact copy of the
245 output created by the original C++ code, and is extremely fast.")
246 (license license:asl2.0)))
247
248 (define-public java-jbzip2
249 (package
250 (name "java-jbzip2")
251 (version "0.9.1")
252 (source (origin
253 (method url-fetch)
254 (uri (string-append "https://storage.googleapis.com/"
255 "google-code-archive-source/v2/"
256 "code.google.com/jbzip2/"
257 "source-archive.zip"))
258 (file-name (string-append name "-" version ".zip"))
259 (sha256
260 (base32
261 "0ncmhlqmrfmj96nqf6p77b9ws35lcfsvpfxzwxi2asissc83z1l3"))))
262 (build-system ant-build-system)
263 (native-inputs
264 (list unzip java-junit))
265 (arguments
266 `(#:tests? #f ; no tests
267 #:jar-name "jbzip2.jar"
268 #:source-dir "tags/release-0.9.1/src"
269 #:phases
270 (modify-phases %standard-phases
271 (add-after 'unpack 'fix-encoding-problems
272 (lambda _
273 ;; Some of the files we're patching are
274 ;; ISO-8859-1-encoded, so choose it as the default
275 ;; encoding so the byte encoding is preserved.
276 (with-fluids ((%default-port-encoding #f))
277 (substitute* "tags/release-0.9.1/src/org/itadaki/bzip2/HuffmanAllocator.java"
278 (("Milidi.") "Milidiu")))
279 #t)))))
280 (home-page "https://code.google.com/archive/p/jbzip2/")
281 (synopsis "Java bzip2 compression/decompression library")
282 (description "Jbzip2 is a Java bzip2 compression/decompression library.
283 It can be used as a replacement for the Apache @code{CBZip2InputStream} /
284 @code{CBZip2OutputStream} classes.")
285 (license license:expat)))
286
287 (define-public java-xz
288 (package
289 (name "java-xz")
290 (version "1.9")
291 (source (origin
292 (method url-fetch/zipbomb)
293 (uri (string-append "https://tukaani.org/xz/xz-java-" version ".zip"))
294 (sha256
295 (base32
296 "007d9f83277qn70swz9inqhyf0qxq6ygajpq5rqg0xgsyh1sdndi"))))
297 (build-system ant-build-system)
298 (arguments
299 `(#:tests? #f; no tests
300 #:jdk ,openjdk9
301 #:phases
302 (modify-phases %standard-phases
303 (add-before 'install 'generate-pom
304 (lambda _
305 (copy-file "maven/pom_template.xml" "pom.xml")
306 (substitute* "pom.xml"
307 (("@VERSION@") ,version)
308 (("@TITLE@") "XZ data compression")
309 (("@HOMEPAGE@") "http://tukaani.org/xz/java.html"))
310 #t))
311 (add-before 'install 'rename-jar
312 (lambda _
313 (rename-file "build/jar/xz.jar"
314 (string-append "build/jar/xz-" ,version ".jar"))
315 #t))
316 (replace 'install
317 (install-from-pom "pom.xml")))))
318 (native-inputs
319 (list unzip))
320 (home-page "https://tukaani.org")
321 (synopsis "XZ in Java")
322 (description "Tukaani-xz is an implementation of xz compression/decompression
323 algorithms in Java.")
324 (license license:public-domain)))