Changeset 13845


Ignore:
Timestamp:
02/02/12 22:08:46 (9 years ago)
Author:
Mark Evenson
Message:

Refactor previous commit into something (slightly) less hideous.

Maybe, I shouldn't write code sober.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp

    r13844 r13845  
    3939Returns the path of the Maven executable or nil if none are found."
    4040
    41   (when (and (asdf:getenv "M2_HOME")  ;; TODO "anaphor" me!
    42              (probe-file (asdf:getenv "M2_HOME")))
    43     (let* ((m2-home (truename (asdf:getenv "M2_HOME")))
    44            (mvn-executable (if (find :unix *features*)
     41  (let ((m2-home (asdf:getenv "M2_HOME"))
     42        (m2 (asdf:getenv "M@"))
     43        (mvn-executable (if (find :unix *features*)
    4544                               "mvn"
    46                                "mvn.bat"))
    47            (mvn-path (merge-pathnames
    48                       (format nil "bin/~A" mvn-executable)
    49                       m2-home))
    50            (mvn (truename mvn-path)))
    51       (if mvn
    52           (return-from find-mvn mvn)
    53           (warn "M2_HOME was set to '~A' in the process environment but '~A' doesn't exist."
    54                 m2-home mvn-path))))
    55   (when (and (asdf:getenv "M2")  ;; TODO "anaphor" me!
    56              (probe-file (asdf:getenv "M2")))
    57         (let* ((m2 (truename (asdf:getenv "M2")))
    58                (mvn-executable (if (find :unix *features*)
    59                                    "mvn"
    60                                    "mvn.bat"))
    61                (mvn-path (merge-pathnames mvn-executable m2))
    62                (mvn (truename mvn-path)))
    63           (if mvn
    64               (return-from find-mvn mvn)
    65               (warn "M2 was set to '~A' in the process environment but '~A' doesn't exist."
    66                     m2 mvn-path))))
    67   (let* ((which-cmd
    68     (if (find :unix *features*)
    69         "which"
    70         ;; Starting with Windows Server 2003
    71         "where.exe"))
    72    (which-cmd-p
    73            (handler-case
    74          (sys::run-program which-cmd nil)
    75        (t () nil))))
    76     (when which-cmd-p
    77       (dolist (mvn-path *mavens*)
    78   (let ((mvn
    79          (handler-case
    80        (truename (read-line (sys::process-output
    81            (sys::run-program
    82             which-cmd `(,mvn-path)))))
    83      (end-of-file () nil)
    84      (t (e)
    85        (format *maven-verbose*
    86          "~&Failed to find Maven executable '~A' in PATH because~&~A"
    87          mvn-path e)))))
    88     (when mvn
    89       (return-from find-mvn mvn)))))))
     45                               "mvn.bat")))
     46    (when (and m2-home (probe-file m2-home))
     47      (let* ((m2-home (truename m2-home))
     48             (mvn-path (merge-pathnames
     49                        (format nil "bin/~A" mvn-executable)
     50                        m2-home))
     51             (mvn (truename mvn-path)))
     52        (if mvn
     53            (return-from find-mvn mvn)
     54            (warn "M2_HOME was set to '~A' in the process environment but '~A' doesn't exist."
     55                  m2-home mvn-path))))
     56    (when (and m2 (probe-file m2))
     57      (let* ((m2 (truename m2))
     58             (mvn-path (merge-pathnames mvn-executable m2))
     59             (mvn (truename mvn-path)))
     60        (if mvn
     61            (return-from find-mvn mvn)
     62            (warn "M2 was set to '~A' in the process environment but '~A' doesn't exist."
     63                  m2 mvn-path))))
     64    (let* ((which-cmd
     65            (if (find :unix *features*)
     66                "which"
     67                ;; Starting with Windows Server 2003
     68                "where.exe"))
     69           (which-cmd-p
     70            (handler-case
     71                (sys::run-program which-cmd nil)
     72              (t () nil))))
     73      (when which-cmd-p
     74        (dolist (mvn-path *mavens*)
     75          (let ((mvn
     76                 (handler-case
     77                     (truename (read-line (sys::process-output
     78                                           (sys::run-program
     79                                            which-cmd `(,mvn-path)))))
     80                   (end-of-file () nil)
     81                   (t (e)
     82                     (format *maven-verbose*
     83                             "~&Failed to find Maven executable '~A' in PATH because~&~A"
     84                             mvn-path e)))))
     85            (when mvn
     86              (return-from find-mvn mvn))))))))
    9087
    9188(defun find-mvn-libs ()
Note: See TracChangeset for help on using the changeset viewer.