ant.scm 5.8 KB

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