1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix build clojure-build-system)
20 #:use-module ((guix build ant-build-system)
21 #:select ((%standard-phases . %standard-phases@ant)
23 #:use-module (guix build clojure-utils)
24 #:use-module (guix build java-utils)
25 #:use-module (guix build utils)
26 #:use-module (srfi srfi-1)
27 #:use-module (srfi srfi-26)
28 #:export (%standard-phases
33 ;; Builder-side code of the standard build procedure for Clojure packages.
38 source-dirs compile-dir
39 jar-names main-class omit-source?
40 aot-include aot-exclude
42 "Standard 'build' phase for clojure-build-system."
43 (let* ((libs (append-map find-clojure-libs source-dirs))
44 (libs* (include-list\exclude-list aot-include
48 (eval-with-clojure `(run! compile ',libs*)
50 (let ((source-dir-files-alist (map (lambda (dir)
51 (cons dir (find-files* dir)))
53 ;; workaround transitive compilation in Clojure
54 (classes (filter (lambda (class)
55 (any (cut compiled-from? class <>)
57 (find-files* compile-dir))))
58 (for-each (cut create-jar <> (cons (cons compile-dir classes)
61 source-dir-files-alist))
62 #:main-class main-class)
69 tests? test-include test-exclude
71 "Standard 'check' phase for clojure-build-system. Note that TEST-EXCLUDE has
72 priority over TEST-INCLUDE."
74 (let* ((libs (append-map find-clojure-libs test-dirs))
75 (libs* (include-list\exclude-list test-include
78 (for-each (lambda (jar)
79 (eval-with-clojure `(do (apply require
80 '(clojure.test ,@libs*))
81 (apply clojure.test/run-tests
83 (cons jar test-dirs)))
87 (define-with-docs install
88 "Standard 'install' phase for clojure-build-system."
91 (define-with-docs %standard-phases
92 "Standard build phases for clojure-build-system."
93 (modify-phases %standard-phases@ant
94 (replace 'build build)
95 (replace 'check check)
96 (replace 'install install)
97 (add-after 'install-license-files 'install-doc install-doc)))
99 (define* (clojure-build #:key
101 (phases %standard-phases)
104 "Build the given Clojure package, applying all of PHASES in order."
110 ;;; clojure-build-system.scm ends here