Changeset 13844


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

abcl-asdf: robustify strategy for finding Maven, especially under Windows.

The [Maven installation instructions][maven-install] instruct the user
of Maven to set the environment variables M2_HOME and M2 to reflect
the local installation path, so before we start searching the
environment's PATH, try to probe these locations for the 'mvn'
executable.

[maven-install]: http://maven.apache.org/download.html

Use "where.exe" instead of "which" under Windows for the fallback
strategy if the user has set neither the M2_HOME or M2 variables.
"where.exe" was shipped as part of Windows Server 2003, so it may not
be universally available.

File:
1 edited

Legend:

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

    r13841 r13844  
    1 ;;; Use the Aether system in a default Maven3 distribution to download
    2 ;;; and install dependencies.
    3 ;;;
    4 ;;; References:
    5 ;;; -- javadoc
    6 ;;; http://sonatype.github.com/sonatype-aether/apidocs/overview-summary.html
    7 ;;; -- incomplete, seemingly often wrong
    8 ;;; https://docs.sonatype.org/display/AETHER/Home
     1;;;; Use the Aether system in a localy installed Maven3 distribution to download
     2;;;; and install JVM artifact dependencies.
     3
     4#|
     5
     6# Implementation references
     7
     8## Installing Maven
     9
     10## Current Javadoc for Maven Aether connector
     11http://sonatype.github.com/sonatype-aether/apidocs/overview-summary.html
     12
     13## Incomplete, seemingly often wrong
     14https://docs.sonatype.org/display/AETHER/Home
     15
     16|#
    917
    1018(in-package :abcl-asdf)
     
    2735
    2836(defun find-mvn ()
    29   "Attempt to find a suitable Maven ('mvn') executable on the hosting operating system."
    30   (dolist (mvn-path *mavens*)
    31     (let ((mvn
     37  "Attempt to find a suitable Maven ('mvn') executable on the hosting operating system.
     38
     39Returns the path of the Maven executable or nil if none are found."
     40
     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*)
     45                               "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
    3273           (handler-case
    33                (truename (read-line (sys::process-output
    34                                      (sys::run-program "which" `(,mvn-path))))) ;; TODO equivalent for MSDOS
    35              (end-of-file () nil))))
    36       (when mvn
    37         (return-from find-mvn mvn)))))
     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)))))))
    3890
    3991(defun find-mvn-libs ()
Note: See TracChangeset for help on using the changeset viewer.