diff options
-rw-r--r-- | guix/build-system/clojure.scm | 6 | ||||
-rw-r--r-- | guix/build/clojure-build-system.scm | 36 | ||||
-rw-r--r-- | guix/build/clojure-utils.scm | 10 |
3 files changed, 44 insertions, 8 deletions
diff --git a/guix/build-system/clojure.scm b/guix/build-system/clojure.scm index 634854cf1b..2a0713d297 100644 --- a/guix/build-system/clojure.scm +++ b/guix/build-system/clojure.scm @@ -107,8 +107,10 @@ #:key source (source-dirs `',%source-dirs) + (java-source-dirs `',%java-source-dirs) (test-dirs `',%test-dirs) (compile-dir %compile-dir) + (java-compile-dir %java-compile-dir) (jar-names `',(package-name->jar-names name)) (main-class %main-class) @@ -142,9 +144,11 @@ #:source #+source #:source-dirs #$source-dirs + #:java-source-dirs #$java-source-dirs #:test-dirs #$test-dirs #:compile-dir #$compile-dir - + #:java-compile-dir #$java-compile-dir + #:jar-names #$jar-names #:main-class #$main-class #:omit-source? #$omit-source? diff --git a/guix/build/clojure-build-system.scm b/guix/build/clojure-build-system.scm index dd01f95de8..7d494078ea 100644 --- a/guix/build/clojure-build-system.scm +++ b/guix/build/clojure-build-system.scm @@ -34,8 +34,24 @@ ;; ;; Code: +(define* (compile-java #:key + java-source-dirs java-compile-dir + #:allow-other-keys) + "Compile java sources for use in clojure-build-system." + (let ((java-files (append-map (lambda (dir) + (find-files dir "\\.java$")) + java-source-dirs))) + (mkdir-p java-compile-dir) + (when (not (null? java-files)) + (apply invoke + "javac" + "-verbose" + "-d" java-compile-dir + java-files)))) + (define* (build #:key - source-dirs compile-dir + source-dirs java-source-dirs + compile-dir java-compile-dir jar-names main-class omit-source? aot-include aot-exclude #:allow-other-keys) @@ -46,19 +62,24 @@ #:all-list libs))) (mkdir-p compile-dir) (eval-with-clojure `(run! compile ',libs*) - source-dirs) + (cons* compile-dir + java-compile-dir + source-dirs)) (let ((source-dir-files-alist (map (lambda (dir) (cons dir (find-files* dir))) - source-dirs)) + (append source-dirs + java-source-dirs))) ;; workaround transitive compilation in Clojure (classes (filter (lambda (class) (any (cut compiled-from? class <>) libs*)) (find-files* compile-dir)))) - (for-each (cut create-jar <> (cons (cons compile-dir classes) - (if omit-source? - '() - source-dir-files-alist)) + (for-each (cut create-jar <> (cons* (cons compile-dir classes) + (cons java-compile-dir + (find-files* java-compile-dir)) + (if omit-source? + '() + source-dir-files-alist)) #:main-class main-class) jar-names) #t))) @@ -94,6 +115,7 @@ priority over TEST-INCLUDE." (define-with-docs %standard-phases "Standard build phases for clojure-build-system." (modify-phases %standard-phases@ant + (add-before 'build 'compile-java compile-java) (replace 'build build) (replace 'check check) (replace 'install install) diff --git a/guix/build/clojure-utils.scm b/guix/build/clojure-utils.scm index 8817cab52a..c5322141d3 100644 --- a/guix/build/clojure-utils.scm +++ b/guix/build/clojure-utils.scm @@ -32,8 +32,10 @@ install-doc %source-dirs + %java-source-dirs %test-dirs %compile-dir + %java-compile-dir package-name->jar-names %main-class %omit-source? @@ -101,6 +103,10 @@ DOC-REGEX can be compiled or uncompiled." "A default list of source directories." '("src/")) +(define-with-docs %java-source-dirs + "A default list of java source directories." + '()) + (define-with-docs %test-dirs "A default list of test directories." '("test/")) @@ -109,6 +115,10 @@ DOC-REGEX can be compiled or uncompiled." "Default directory for holding class files." "classes/") +(define-with-docs %java-compile-dir + "Default directory for holding java class files." + "java-classes/") + (define (package-name->jar-names name) "Given NAME, a package name like \"foo-0.9.1b\", return the list of default jar names: (\"foo-0.9.1b.jar\" \"foo.jar\")." |