gnu: ruby-pandoc-ruby: Use pandoc instead of ghc-pandoc.
[jackhill/guix/guix.git] / gnu / packages / java-compression.scm
CommitLineData
24155bf4
RW
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>
ca0fe294 6;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
24155bf4
RW
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)
0308944a 28 #:use-module (guix git-download)
24155bf4
RW
29 #:use-module (guix build-system ant)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages java)
4fec042b
RW
33 #:use-module (gnu packages perl)
34 #:use-module (gnu packages python-compression))
24155bf4
RW
35
36(define-public java-snappy
37 (package
38 (name "java-snappy")
affae324 39 (version "1.1.7.5")
0308944a
TGR
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
affae324 47 (base32 "0894zyasrmbi268d1ky9db16wrnc6x8b9ilq0b5paaxi2pwgjlrp"))
0308944a 48 (file-name (git-file-name name version))))
24155bf4
RW
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
0308944a
TGR
55 (add-after 'unpack 'make-git-checkout-writable
56 (lambda _
57 (for-each make-file-writable (find-files "."))
58 #t))
24155bf4
RW
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++
128compressor/decompressor.")
129 (license license:asl2.0)))
130
131(define-public java-snappy-1
132 (package
133 (inherit java-snappy)
e2528a3c 134 (name "java-snappy")
24155bf4 135 (version "1.0.3-rc3")
e2528a3c
TGR
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))))
24155bf4
RW
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")
287e3d31
TGR
196 (source
197 (origin
198 (method git-fetch)
199 (uri (git-reference
200 (url "https://github.com/dain/snappy")
201 (commit (string-append "snappy-" version))))
202 (sha256
203 (base32 "1mswh207065rdzbxk6rxaqlxhbg1ngxa0vjc20knsn31kqbq1bcz"))
204 (file-name (git-file-name name version))))
24155bf4
RW
205 (build-system ant-build-system)
206 (arguments
207 `(#:jar-name "iq80-snappy.jar"
208 #:source-dir "src/main/java"
209 #:test-dir "src/test"
24155bf4
RW
210 #:phases
211 (modify-phases %standard-phases
212 (replace 'check
213 (lambda _
214 (define (test class)
215 (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
216 ":build/classes"
217 ":build/test-classes")
218 "-Dtest.resources.dir=src/test/resources"
219 "org.testng.TestNG" "-testclass"
220 class))
221 (invoke "ant" "compile-tests")
222 (test "org.iq80.snappy.SnappyFramedStreamTest")
223 (test "org.iq80.snappy.SnappyStreamTest")
224 #t))
225 (add-before 'build 'remove-hadoop-dependency
226 (lambda _
227 ;; We don't have hadoop
228 (delete-file "src/main/java/org/iq80/snappy/HadoopSnappyCodec.java")
229 (delete-file "src/test/java/org/iq80/snappy/TestHadoopSnappyCodec.java")
02ed96dc
JL
230 #t))
231 (replace 'install (install-from-pom "pom.xml")))))
24155bf4
RW
232 (home-page "https://github.com/dain/snappy")
233 (native-inputs
51087d51 234 `(("java-guava" ,java-guava)
24155bf4 235 ("java-snappy" ,java-snappy)
51087d51 236 ("java-testng" ,java-testng)))
24155bf4
RW
237 (synopsis "Java port of the Snappy (de)compressor")
238 (description
239 "Iq80-snappy is a port of the Snappy compressor and decompressor rewritten
240in pure Java. This compression code produces a byte-for-byte exact copy of the
241output created by the original C++ code, and is extremely fast.")
242 (license license:asl2.0)))
243
244(define-public java-jbzip2
245 (package
246 (name "java-jbzip2")
247 (version "0.9.1")
248 (source (origin
249 (method url-fetch)
250 (uri (string-append "https://storage.googleapis.com/"
251 "google-code-archive-source/v2/"
252 "code.google.com/jbzip2/"
253 "source-archive.zip"))
254 (file-name (string-append name "-" version ".zip"))
255 (sha256
256 (base32
257 "0ncmhlqmrfmj96nqf6p77b9ws35lcfsvpfxzwxi2asissc83z1l3"))))
258 (build-system ant-build-system)
259 (native-inputs
260 `(("unzip" ,unzip)
261 ("java-junit" ,java-junit)))
262 (arguments
263 `(#:tests? #f ; no tests
264 #:jar-name "jbzip2.jar"
265 #:source-dir "tags/release-0.9.1/src"
266 #:phases
267 (modify-phases %standard-phases
268 (add-after 'unpack 'fix-encoding-problems
269 (lambda _
270 ;; Some of the files we're patching are
271 ;; ISO-8859-1-encoded, so choose it as the default
272 ;; encoding so the byte encoding is preserved.
273 (with-fluids ((%default-port-encoding #f))
274 (substitute* "tags/release-0.9.1/src/org/itadaki/bzip2/HuffmanAllocator.java"
275 (("Milidi.") "Milidiu")))
276 #t)))))
277 (home-page "https://code.google.com/archive/p/jbzip2/")
278 (synopsis "Java bzip2 compression/decompression library")
279 (description "Jbzip2 is a Java bzip2 compression/decompression library.
280It can be used as a replacement for the Apache @code{CBZip2InputStream} /
281@code{CBZip2OutputStream} classes.")
282 (license license:expat)))
283
d308bc01 284(define-public java-xz
24155bf4 285 (package
d308bc01 286 (name "java-xz")
24155bf4
RW
287 (version "1.6")
288 (source (origin
289 (method url-fetch)
290 (uri (string-append "https://tukaani.org/xz/xz-java-" version ".zip"))
291 (sha256
292 (base32
293 "1z3p1ri1gvl07inxn0agx44ck8n7wrzfmvkz8nbq3njn8r9wba8x"))))
294 (build-system ant-build-system)
295 (arguments
296 `(#:tests? #f; no tests
297 #:phases
298 (modify-phases %standard-phases
299 (add-after 'unpack 'chdir
300 (lambda _
301 ;; Our build system enters the first directory in the archive, but
302 ;; the package is not contained in a subdirectory
303 (chdir "..")
304 #t))
02ed96dc
JL
305 (add-before 'install 'generate-pom
306 (lambda _
307 (copy-file "maven/pom_template.xml" "pom.xml")
308 (substitute* "pom.xml"
309 (("@VERSION@") ,version)
310 (("@TITLE@") "XZ data compression")
311 (("@HOMEPAGE@") "http://tukaani.org/xz/java.html"))
312 #t))
313 (add-before 'install 'rename-jar
314 (lambda _
315 (rename-file "build/jar/xz.jar"
316 (string-append "build/jar/xz-" ,version ".jar"))
317 #t))
318 (replace 'install
319 (install-from-pom "pom.xml")))))
24155bf4
RW
320 (native-inputs
321 `(("unzip" ,unzip)))
322 (home-page "https://tukaani.org")
323 (synopsis "XZ in Java")
324 (description "Tukaani-xz is an implementation of xz compression/decompression
325algorithms in Java.")
326 (license license:public-domain)))