Commit | Line | Data |
---|---|---|
5f7a1a4d RW |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
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. | |
10 | ;;; | |
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. | |
15 | ;;; | |
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/>. | |
18 | ||
19 | (define-module (guix build-system ant) | |
20 | #:use-module (guix store) | |
21 | #:use-module (guix utils) | |
22 | #:use-module (guix packages) | |
23 | #:use-module (guix derivations) | |
24 | #:use-module (guix search-paths) | |
25 | #:use-module (guix build-system) | |
26 | #:use-module (guix build-system gnu) | |
27 | #:use-module (ice-9 match) | |
28 | #:use-module (srfi srfi-26) | |
29 | #:export (%ant-build-system-modules | |
30 | ant-build | |
31 | ant-build-system)) | |
32 | ||
33 | ;; Commentary: | |
34 | ;; | |
35 | ;; Standard build procedure for Java packages using Ant. | |
36 | ;; | |
37 | ;; Code: | |
38 | ||
39 | (define %ant-build-system-modules | |
40 | ;; Build-side modules imported by default. | |
41 | `((guix build ant-build-system) | |
59135f0d | 42 | (guix build java-utils) |
5f7a1a4d RW |
43 | (guix build syscalls) |
44 | ,@%gnu-build-system-modules)) | |
45 | ||
46 | (define (default-jdk) | |
47 | "Return the default JDK package." | |
48 | ;; Lazily resolve the binding to avoid a circular dependency. | |
49 | (let ((jdk-mod (resolve-interface '(gnu packages java)))) | |
50 | (module-ref jdk-mod 'icedtea))) | |
51 | ||
52 | (define (default-ant) | |
53 | "Return the default Ant package." | |
54 | ;; Lazily resolve the binding to avoid a circular dependency. | |
55 | (let ((jdk-mod (resolve-interface '(gnu packages java)))) | |
56 | (module-ref jdk-mod 'ant))) | |
57 | ||
ab50bba9 RW |
58 | (define (default-zip) |
59 | "Return the default ZIP package." | |
60 | ;; Lazily resolve the binding to avoid a circular dependency. | |
148585c2 | 61 | (let ((zip-mod (resolve-interface '(gnu packages compression)))) |
ab50bba9 RW |
62 | (module-ref zip-mod 'zip))) |
63 | ||
5f7a1a4d RW |
64 | (define* (lower name |
65 | #:key source inputs native-inputs outputs system target | |
66 | (jdk (default-jdk)) | |
67 | (ant (default-ant)) | |
ab50bba9 | 68 | (zip (default-zip)) |
5f7a1a4d RW |
69 | #:allow-other-keys |
70 | #:rest arguments) | |
71 | "Return a bag for NAME." | |
72 | (define private-keywords | |
ab50bba9 | 73 | '(#:source #:target #:jdk #:ant #:zip #:inputs #:native-inputs)) |
5f7a1a4d RW |
74 | |
75 | (and (not target) ;XXX: no cross-compilation | |
76 | (bag | |
77 | (name name) | |
78 | (system system) | |
79 | (host-inputs `(,@(if source | |
80 | `(("source" ,source)) | |
81 | '()) | |
82 | ,@inputs | |
83 | ||
84 | ;; Keep the standard inputs of 'gnu-build-system'. | |
85 | ,@(standard-packages))) | |
86 | (build-inputs `(("jdk" ,jdk "jdk") | |
87 | ("ant" ,ant) | |
ab50bba9 | 88 | ("zip" ,zip) |
5f7a1a4d RW |
89 | ,@native-inputs)) |
90 | (outputs outputs) | |
91 | (build ant-build) | |
92 | (arguments (strip-keyword-arguments private-keywords arguments))))) | |
93 | ||
94 | (define* (ant-build store name inputs | |
95 | #:key | |
96 | (tests? #t) | |
52a791f5 | 97 | (test-target "check") |
5f7a1a4d RW |
98 | (configure-flags ''()) |
99 | (make-flags ''()) | |
100 | (build-target "jar") | |
101 | (jar-name #f) | |
8df1faa0 | 102 | (main-class #f) |
f403d7ab JL |
103 | (test-include (list "**/*Test.java")) |
104 | (test-exclude (list "**/Abstract*.java")) | |
8df64f73 | 105 | (source-dir "src") |
52a791f5 | 106 | (test-dir "src/test") |
5f7a1a4d RW |
107 | (phases '(@ (guix build ant-build-system) |
108 | %standard-phases)) | |
109 | (outputs '("out")) | |
110 | (search-paths '()) | |
111 | (system (%current-system)) | |
59c3e984 | 112 | (guile #f) |
5f7a1a4d RW |
113 | (imported-modules %ant-build-system-modules) |
114 | (modules '((guix build ant-build-system) | |
59135f0d | 115 | (guix build java-utils) |
5f7a1a4d RW |
116 | (guix build utils)))) |
117 | "Build SOURCE with INPUTS." | |
118 | (define builder | |
119 | `(begin | |
120 | (use-modules ,@modules) | |
121 | (ant-build #:name ,name | |
122 | #:source ,(match (assoc-ref inputs "source") | |
123 | (((? derivation? source)) | |
124 | (derivation->output-path source)) | |
125 | ((source) | |
126 | source) | |
127 | (source | |
128 | source)) | |
129 | #:make-flags ,make-flags | |
130 | #:configure-flags ,configure-flags | |
131 | #:system ,system | |
132 | #:tests? ,tests? | |
133 | #:test-target ,test-target | |
134 | #:build-target ,build-target | |
135 | #:jar-name ,jar-name | |
8df1faa0 | 136 | #:main-class ,main-class |
f403d7ab JL |
137 | #:test-include (list ,@test-include) |
138 | #:test-exclude (list ,@test-exclude) | |
8df64f73 | 139 | #:source-dir ,source-dir |
52a791f5 | 140 | #:test-dir ,test-dir |
5f7a1a4d RW |
141 | #:phases ,phases |
142 | #:outputs %outputs | |
143 | #:search-paths ',(map search-path-specification->sexp | |
144 | search-paths) | |
145 | #:inputs %build-inputs))) | |
146 | ||
147 | (define guile-for-build | |
148 | (match guile | |
149 | ((? package?) | |
150 | (package-derivation store guile system #:graft? #f)) | |
151 | (#f ; the default | |
152 | (let* ((distro (resolve-interface '(gnu packages commencement))) | |
153 | (guile (module-ref distro 'guile-final))) | |
154 | (package-derivation store guile system #:graft? #f))))) | |
155 | ||
156 | (build-expression->derivation store name builder | |
157 | #:inputs inputs | |
158 | #:system system | |
159 | #:modules imported-modules | |
160 | #:outputs outputs | |
161 | #:guile-for-build guile-for-build)) | |
162 | ||
163 | (define ant-build-system | |
164 | (build-system | |
165 | (name 'ant) | |
166 | (description "The standard Ant build system") | |
167 | (lower lower))) | |
168 | ||
169 | ;;; ant.scm ends here |