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