1 | (in-package :abcl/build) |
---|
2 | |
---|
3 | ;; TODO function to deal with looking up a locally preferred mirrors |
---|
4 | (defun ant-zip-uri () |
---|
5 | #p"http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.4-bin.zip" |
---|
6 | |
---|
7 | #+(or) ;; https on OPEN fails; probably attempting to upgrade |
---|
8 | #p"https://archive.apache.org/dist/ant/binaries/apache-ant-1.9.4-bin.zip" |
---|
9 | |
---|
10 | #+(or) ;; need apache-ant-1.9 for JVM version 49.0 |
---|
11 | #p"http://www-eu.apache.org/dist/ant/binaries/apache-ant-1.10.1-bin.zip") |
---|
12 | |
---|
13 | (defun xdg/ant-executable () |
---|
14 | (xdg/executable (ant-zip-uri) "bin/ant")) |
---|
15 | |
---|
16 | #+(or) |
---|
17 | (defun xdg/ant-executable () |
---|
18 | (let* ((uri (ant-zip-uri)) |
---|
19 | (directory (xdg/abcl-install-root uri)) |
---|
20 | (ant-root-name (let ((name (pathname-name uri))) |
---|
21 | (subseq name 0 (- (length name) (length "-bin"))))) |
---|
22 | (ant-home (merge-pathnames (make-pathname :directory `(:relative ,ant-root-name)) |
---|
23 | directory)) |
---|
24 | (ant (merge-pathnames #p"bin/ant" ant-home)) |
---|
25 | result) |
---|
26 | (dolist (p (possible-executable-names ant)) |
---|
27 | (when (probe-file p) |
---|
28 | (return-from xdg/ant-executable |
---|
29 | (values |
---|
30 | (probe-file p) |
---|
31 | ant)))) |
---|
32 | ;; failure |
---|
33 | (values |
---|
34 | nil |
---|
35 | ant))) |
---|
36 | |
---|
37 | (defun ant/install () |
---|
38 | (unless (xdg/ant-executable) |
---|
39 | (xdg/install (ant-zip-uri) :type :unzip)) |
---|
40 | (values |
---|
41 | (xdg/ant-executable) |
---|
42 | (directory (merge-pathnames "**/*" |
---|
43 | (xdg/abcl-install-root (ant-zip-uri)))))) |
---|
44 | |
---|
45 | (defparameter *ant-home* nil) |
---|
46 | |
---|
47 | (define-condition no-installed-ant (error) |
---|
48 | ((searched)) |
---|
49 | (:report (lambda (condition stream) |
---|
50 | (format stream "Unable to introspect Apache Ant installation.")))) |
---|
51 | |
---|
52 | ;; TODO after this routines executes *ANT-EXECUTABLE-DIRECTORY* and XDG/ANT-EXECUTABLE will work |
---|
53 | (defun ensure-ant (&key (ant-home nil ant-home-p)) |
---|
54 | (cond |
---|
55 | ((and (null ant-home) ant-home-p) |
---|
56 | (warn "Unimplemented explicit auto-configuration run.")) |
---|
57 | ((and ant-home ant-home-p) |
---|
58 | (warn "Unimplemented explicit configuration with specified directory directory.")) |
---|
59 | (t |
---|
60 | (if *ant-home* |
---|
61 | *ant-home* |
---|
62 | (restart-case |
---|
63 | (let ((ant-home (some-directory-containing "ant"))) |
---|
64 | (unless ant-home |
---|
65 | (signal 'no-installed-ant)) |
---|
66 | (setf *ant-home ant-home)) |
---|
67 | (install-ant () |
---|
68 | (ant/install))))))) |
---|
69 | |
---|
70 | (defmacro with-ensured-ant ((ant) &body body) |
---|
71 | `(progn |
---|
72 | (unless ,ant |
---|
73 | (setf ,ant (ensure-ant))) |
---|
74 | ,@body)) |
---|
75 | |
---|
76 | (defun ant/call (ant-file target-or-targets) |
---|
77 | (let (ant) |
---|
78 | (with-ensured-ant (ant) |
---|
79 | (uiop:run-program |
---|
80 | `(,ant "-buildfile" |
---|
81 | ,(stringify ant-file) |
---|
82 | ,@(listify target-or-targets)) |
---|
83 | :output :string)))) |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|