ant.scm 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
  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. (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 gexp)
  24. #:use-module (guix monads)
  25. #:use-module (guix search-paths)
  26. #:use-module (guix build-system)
  27. #:use-module (guix build-system gnu)
  28. #:use-module (ice-9 match)
  29. #:use-module (srfi srfi-26)
  30. #:export (%ant-build-system-modules
  31. ant-build
  32. ant-build-system))
  33. ;; Commentary:
  34. ;;
  35. ;; Standard build procedure for Java packages using Ant.
  36. ;;
  37. ;; Code:
  38. (define %ant-build-system-modules
  39. ;; Build-side modules imported by default.
  40. `((guix build ant-build-system)
  41. (guix build maven java)
  42. (guix build maven plugin)
  43. (guix build maven pom)
  44. (guix build java-utils)
  45. (guix build syscalls)
  46. ,@%gnu-build-system-modules))
  47. (define (default-jdk)
  48. "Return the default JDK package."
  49. ;; Lazily resolve the binding to avoid a circular dependency.
  50. (let ((jdk-mod (resolve-interface '(gnu packages java))))
  51. (module-ref jdk-mod 'icedtea)))
  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. (define (default-zip)
  58. "Return the default ZIP package."
  59. ;; Lazily resolve the binding to avoid a circular dependency.
  60. (let ((zip-mod (resolve-interface '(gnu packages compression))))
  61. (module-ref zip-mod 'zip)))
  62. (define* (lower name
  63. #:key source inputs native-inputs outputs system target
  64. (jdk (default-jdk))
  65. (ant (default-ant))
  66. (zip (default-zip))
  67. #:allow-other-keys
  68. #:rest arguments)
  69. "Return a bag for NAME."
  70. (define private-keywords
  71. '(#:target #:jdk #:ant #:zip #:inputs #:native-inputs))
  72. (and (not target) ;XXX: no cross-compilation
  73. (bag
  74. (name name)
  75. (system system)
  76. (host-inputs `(,@(if source
  77. `(("source" ,source))
  78. '())
  79. ,@inputs
  80. ;; Keep the standard inputs of 'gnu-build-system'.
  81. ,@(standard-packages)))
  82. (build-inputs `(("jdk" ,jdk "jdk")
  83. ("ant" ,ant)
  84. ("zip" ,zip)
  85. ,@native-inputs))
  86. (outputs outputs)
  87. (build ant-build)
  88. (arguments (strip-keyword-arguments private-keywords arguments)))))
  89. (define* (ant-build name inputs
  90. #:key
  91. source
  92. (tests? #t)
  93. (test-target "check")
  94. (configure-flags ''())
  95. (make-flags ''())
  96. (build-target "jar")
  97. (jar-name #f)
  98. (main-class #f)
  99. (test-include (list "**/*Test.java"))
  100. (test-exclude (list "**/Abstract*.java"))
  101. (source-dir "src")
  102. (test-dir "src/test")
  103. (phases '%standard-phases)
  104. (outputs '("out"))
  105. (search-paths '())
  106. (system (%current-system))
  107. (guile #f)
  108. (imported-modules %ant-build-system-modules)
  109. (modules '((guix build ant-build-system)
  110. (guix build java-utils)
  111. (guix build utils))))
  112. "Build SOURCE with INPUTS."
  113. (define builder
  114. (with-imported-modules imported-modules
  115. #~(begin
  116. (use-modules #$@(sexp->gexp modules))
  117. (ant-build #:name #$name
  118. #:source #+source
  119. #:make-flags #$make-flags
  120. #:configure-flags #$configure-flags
  121. #:system #$system
  122. #:tests? #$tests?
  123. #:test-target #$test-target
  124. #:build-target #$build-target
  125. #:jar-name #$jar-name
  126. #:main-class #$main-class
  127. #:test-include (list #$@test-include)
  128. #:test-exclude (list #$@test-exclude)
  129. #:source-dir #$source-dir
  130. #:test-dir #$test-dir
  131. #:phases #$phases
  132. #:outputs #$(outputs->gexp outputs)
  133. #:search-paths '#$(sexp->gexp
  134. (map search-path-specification->sexp
  135. search-paths))
  136. #:inputs #$(input-tuples->gexp inputs)))))
  137. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  138. system #:graft? #f)))
  139. (gexp->derivation name builder
  140. #:system system
  141. #:guile-for-build guile)))
  142. (define ant-build-system
  143. (build-system
  144. (name 'ant)
  145. (description "The standard Ant build system")
  146. (lower lower)))
  147. ;;; ant.scm ends here