projects/guix·blob graal · refs

357 lines · 15.9 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2019, 2024, 2025 Ricardo Wurmus <[email protected]>
3;;; Copyright © 2023 Frank Pursel <[email protected]>
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu packages java-graphics)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix gexp)
25 #:use-module (guix git-download)
26 #:use-module (guix modules)
27 #:use-module (guix utils)
28 #:use-module (guix build-system ant)
29 #:use-module (guix build utils)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages bash)
32 #:use-module (gnu packages batik)
33 #:use-module (gnu packages java)
34 #:use-module (gnu packages java-xml)
35 #:use-module (gnu packages xml)
36 #:use-module (gnu packages xorg)
37 #:use-module (ice-9 match))
38
39(define-public ditaa
40 (package
41 (name "ditaa")
42 (version "0.11.0")
43 (source (origin
44 (method git-fetch)
45 (uri (git-reference
46 (url "https://github.com/stathissideris/ditaa")
47 (commit (string-append "v" version))))
48 (file-name (git-file-name name version))
49 (sha256
50 (base32
51 "1y3g17wp1wvb05m56pp25avww2njpgh0gk0jsbsf25scj7hyyj26"))
52 (modules '((guix build utils)))
53 (snippet '(begin
54 (format #t "~%~a~%"
55 "Finding and removing embedded jars.")
56 (for-each (lambda (jarf)
57 (delete-file jarf)
58 (format #t "Deleted: ~a~%" jarf))
59 (find-files "." "\\.jar$"))))))
60 (build-system ant-build-system)
61 (inputs (list bash-minimal))
62 (native-inputs (list
63 java-commons-cli
64 java-jericho-html
65 java-junit
66 java-libbatik
67 java-w3c-svg))
68 (arguments
69 `(#:build-target "release-all"
70 #:phases (modify-phases %standard-phases
71 ;; Ant's buildfile and build tree need to be modified
72 ;; to provide access to the guix builds of the
73 ;; batik and the java-commons-cli
74 ;; jar files. Also some of the source requires java7.
75 (add-before 'build 'build-prep
76 (lambda* (#:key inputs outputs #:allow-other-keys)
77 (let* ((batik-jar
78 (search-input-file
79 inputs
80 "share/java/batik.jar"))
81 (commons-cli-jar
82 (search-input-file
83 inputs
84 "lib/m2/commons-cli/commons-cli/1.4/commons-cli-1.4.jar")))
85 (mkdir-p "lib")
86 (copy-file batik-jar "./lib/batik.jar")
87 (copy-file commons-cli-jar "./lib/commons-cli.jar"))
88 (with-directory-excursion "build"
89 (substitute* "release.xml"
90 (("source=\"1.6\"")
91 "source=\"7\"")
92 (("<file name=\"commons-cli-1.2.jar\"/>")
93 (string-append "<file name=\"commons-cli.jar\"/>"
94 "\n" "<file name=\"batik.jar\"/>"))))))
95 (replace 'build
96 (lambda* _
97 (setenv "ANT_OPTS"
98 (string-append "-Dversion.string="
99 ,version))
100 (with-directory-excursion "build"
101 (invoke "ant" "-f" "release.xml" "release-jar"))))
102 (replace 'check
103 (lambda* (#:key tests? #:allow-other-keys)
104 (if tests?
105 (begin
106 (setenv "ANT_OPTS"
107 (string-append "-Dversion.string="
108 ,version))
109 (mkdir-p "tests/testlib")
110 (with-directory-excursion "build"
111 (invoke "ant" "-f" "release.xml"
112 "generate-test-images")
113 (invoke "ant" "test"))) #f)))
114 (replace 'install
115 (lambda* (#:key inputs outputs #:allow-other-keys)
116 (let* ((out (assoc-ref outputs "out"))
117 (lib (string-append out "/lib"))
118 (bin (string-append out "/bin"))
119 (bash (search-input-file inputs "bin/bash"))
120 (java (search-input-file inputs "bin/java"))
121 (jre (search-input-directory inputs "jre"))
122 (ditaa (string-append out "/bin/ditaa"))
123 (jar-name (string-append ,name
124 ,version ".jar")))
125 (with-directory-excursion "releases"
126 (install-file jar-name lib))
127 (mkdir-p bin)
128 (with-output-to-file ditaa
129 (lambda _
130 (format #t
131 "#!~a~%JAVA_HOME=~a ~a -jar ~a/~a $@~%"
132 bash
133 jre
134 java
135 lib
136 jar-name)))
137 (chmod ditaa #o755))))
138 (add-after 'install 'install-docs
139 (lambda* (#:key outputs #:allow-other-keys)
140 (let ((doc (string-append (assoc-ref outputs "out")
141 "/share/doc/")))
142 (for-each (lambda (filen)
143 (install-file filen doc))
144 (find-files "." ".*README\\.md"))))))))
145 (home-page "https://github.com/stathissideris/ditaa")
146 (synopsis "Create graphics from ascii art")
147 (description
148 "ditaa is a small command-line utility that converts diagrams drawn using
149ascii art drawings that contain characters that resemble lines like @samp{|}
150@samp{/} @samp{-}), into proper bitmap graphics.")
151 (license license:lgpl3)))
152
153(define-public java-flatlaf
154 (package
155 (name "java-flatlaf")
156 (version "3.5.4")
157 (source (origin
158 (method git-fetch)
159 (uri (git-reference
160 (url "https://github.com/JFormDesigner/FlatLaf")
161 (commit version)))
162 (file-name (git-file-name name version))
163 (sha256
164 (base32
165 "017n1w6hds4wrz597jk7v8r6pz0kz5j9xwd240nq7s8hc58d4c2q"))
166 (modules '((guix build utils)))
167 (snippet
168 '(for-each
169 delete-file
170 (find-files "flatlaf-core/src/main/resources/com/formdev/flatlaf/natives/"
171 ".*")))))
172 (build-system ant-build-system)
173 (arguments
174 (list
175 #:tests? #false ;XXX requires junit5
176 #:jar-name "flatlaf.jar"
177 #:source-dir '(list "flatlaf-core/src/main/java")
178 #:test-dir '(list "flatlaf-core/src/test")
179 #:phases
180 #~(modify-phases %standard-phases
181 (add-before 'configure 'build-native-code
182 (lambda* (#:key inputs #:allow-other-keys)
183 (let* ((jdk (assoc-ref inputs "jdk"))
184 (suffix #$(match (%current-system)
185 ("i686-linux" "i686")
186 ("armhf-linux" "armhf")
187 ("aarch64-linux" "aarch64")
188 ("x86_64-linux" "x86_64")
189 (_ "generic")))
190 (lib #$(match (%current-system)
191 ("i686-linux"
192 "/lib/i386")
193 ("x86_64-linux"
194 "/lib/amd64")
195 ("armhf-linux"
196 "/lib/arm")
197 ("aarch64-linux"
198 "/lib/aarch64")
199 ("powerpc-linux"
200 "/lib/ppc")
201 ;; We need a catch-all, dropping
202 ;; '-linux' works in most cases.
203 (_
204 (string-append
205 "/lib/"
206 (string-drop-right
207 (%current-system) 6)))))
208 (filename
209 (string-append "libflatlaf-linux-" suffix ".so"))
210 (target-dir
211 (string-append (getcwd)
212 "/flatlaf-core/src/main/resources/com/formdev/flatlaf/natives")))
213 (with-directory-excursion "flatlaf-natives/flatlaf-natives-linux/"
214 (invoke "gcc" "-shared" "-O3" "-fPIC"
215 "src/main/cpp/ApiVersion.cpp"
216 "src/main/cpp/X11WmUtils.cpp"
217 "-Isrc/main/headers"
218 "-ljawt"
219 (string-append "-L" jdk lib)
220 (string-append "-I" jdk "/include")
221 (string-append "-I" jdk "/include/linux")
222 "-o" filename)
223 (install-file filename target-dir)))))
224 (add-before 'build 'copy-resources
225 (lambda _
226 (copy-recursively "flatlaf-core/src/main/resources"
227 "build/classes"))))))
228 (inputs (list libx11 libxt))
229 (home-page "https://www.formdev.com/flatlaf/")
230 (synopsis "Flat Look and Feel for Java Swing applications")
231 (description "FlatLaf is a cross-platform Look and Feel for Java Swing
232desktop applications. It looks almost flat (no shadows or gradients), clean,
233simple and elegant. FlatLaf comes with Light, Dark, IntelliJ and Darcula
234themes, scales on HiDPI displays and runs on Java 8 or newer.
235
236The look is heavily inspired by Darcula and IntelliJ themes from IntelliJ IDEA
2372019.2+ and uses almost the same colors and icons.")
238 (license license:asl2.0)))
239
240(define-public java-flatlaf-intellij-themes
241 (package
242 (inherit java-flatlaf)
243 (name "java-flatlaf-intellij-themes")
244 (arguments
245 (list
246 #:tests? #false ;there are none
247 #:jar-name "flatlaf-intellij-themes.jar"
248 #:source-dir '(list "flatlaf-intellij-themes/src/main/java")
249 #:phases
250 #~(modify-phases %standard-phases
251 (add-before 'build 'copy-resources
252 (lambda _
253 (copy-recursively "flatlaf-intellij-themes/src/main/resources"
254 "build/classes"))))))
255 (inputs (list java-flatlaf))
256 (synopsis "FlatLaf addon with popular themes")
257 (description "This addon for FlatLaf bundles many popular third party
258themes from JetBrains Plugins Repository into a JAR and provides Java classes
259to use them.")))
260
261(define-public java-piccolo2d-core
262 (package
263 (name "java-piccolo2d-core")
264 (version "3.0.1")
265 (source (origin
266 (method git-fetch)
267 (uri (git-reference
268 (url "https://github.com/piccolo2d/piccolo2d.java")
269 (commit (string-append "piccolo2d-complete-" version))))
270 (file-name (git-file-name name version))
271 (sha256
272 (base32
273 "1k6gw643k83516lcw04mgac2yi75phdrng44pz9xk6hz066ip21s"))))
274 (build-system ant-build-system)
275 (arguments
276 `(#:jar-name "piccolo2d-core.jar"
277 #:phases
278 (modify-phases %standard-phases
279 (add-after 'unpack 'chdir
280 (lambda _ (chdir "core") #t)))))
281 (inputs
282 (list java-junit))
283 (home-page "http://piccolo2d.org")
284 (synopsis "Structured 2D graphics framework")
285 (description "Piccolo2D is a framework (in the Jazz ZUI tradition) to
286create robust, full-featured graphical applications in Java, with features
287such as zooming and multiple representation. This package provides the core
288libraries.")
289 (license license:bsd-3)))
290
291(define-public java-piccolo2d-extras
292 (package (inherit java-piccolo2d-core)
293 (name "java-piccolo2d-extras")
294 (arguments
295 `(#:jar-name "piccolo2d-extras.jar"
296 #:phases
297 (modify-phases %standard-phases
298 (add-after 'unpack 'chdir
299 (lambda _ (chdir "extras") #t))
300 (add-after 'chdir 'remove-failing-test
301 (lambda _
302 ;; TODO: These both fail with "Unable to convolve src image"
303 (delete-file "src/test/java/org/piccolo2d/extras/nodes/PShadowTest.java")
304 (delete-file "src/test/java/org/piccolo2d/extras/util/ShadowUtilsTest.java")
305 #t))
306 (add-before 'check 'start-xorg-server
307 (lambda* (#:key inputs #:allow-other-keys)
308 ;; The test suite requires a running X server.
309 (system "Xvfb :1 -screen 0 640x480x24 &")
310 (setenv "DISPLAY" ":1")
311 #t)))))
312 (inputs
313 (list java-piccolo2d-core java-junit))
314 (native-inputs
315 (list xorg-server)) ; for tests
316 (description "Piccolo2D is a framework (in the Jazz ZUI tradition) to
317create robust, full-featured graphical applications in Java, with features
318such as zooming and multiple representation. This package provides additional
319features not found in the core libraries.")))
320
321(define-public java-marlin-renderer
322 (package
323 (name "java-marlin-renderer")
324 (version "0.9.4.8")
325 (source (origin
326 (method git-fetch)
327 (uri (git-reference
328 (url "https://github.com/bourgesl/marlin-renderer")
329 (commit (string-append "v" (string-map (match-lambda
330 (#\. #\_)
331 (c c))
332 version)))))
333 (file-name (git-file-name name version))
334 (sha256
335 (base32
336 "0gcqp9iq0j5n08gdssh8gp0daj3n5zrx0dll1l4ljhbj2b9jm9ym"))))
337 (build-system ant-build-system)
338 (arguments
339 (list
340 #:jar-name "marlin.jar"
341 #:test-include '(list "src/test/java/RunJUnitTest.java")
342 #:phases
343 '(modify-phases %standard-phases
344 (add-before 'build 'copy-resources
345 (lambda _
346 (copy-recursively "src/main/resources" "build/classes"))))))
347 (inputs
348 (list java-hamcrest-core java-junit))
349 (home-page "https://github.com/bourgesl/marlin-renderer/")
350 (synopsis "Rendering engine")
351 (description "Marlin is a Java2D @code{RenderingEngine} optimized for
352performance (improved memory usage and footprint, better multi-threading) and
353better visual quality based on OpenJDK's @code{pisces} implementation. It
354handles shape rendering (@code{Graphics2D} @code{draw(Shape)} /
355@code{fill(Shape)} with stroke and dash attributes.")
356 ;; With Classpath Exception
357 (license license:gpl2)))