[armedbear-cvs] r13844 - trunk/abcl/contrib/abcl-asdf
mevenson at common-lisp.net
mevenson at common-lisp.net
Thu Feb 2 10:11:46 UTC 2012
Author: mevenson
Date: Thu Feb 2 02:11:46 2012
New Revision: 13844
Log:
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.
Modified:
trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp
Modified: trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp Thu Feb 2 01:38:02 2012 (r13843)
+++ trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp Thu Feb 2 02:11:46 2012 (r13844)
@@ -1,11 +1,19 @@
-;;; Use the Aether system in a default Maven3 distribution to download
-;;; and install dependencies.
-;;;
-;;; References:
-;;; -- javadoc
-;;; http://sonatype.github.com/sonatype-aether/apidocs/overview-summary.html
-;;; -- incomplete, seemingly often wrong
-;;; https://docs.sonatype.org/display/AETHER/Home
+;;;; Use the Aether system in a localy installed Maven3 distribution to download
+;;;; and install JVM artifact dependencies.
+
+#|
+
+# Implementation references
+
+## Installing Maven
+
+## Current Javadoc for Maven Aether connector
+http://sonatype.github.com/sonatype-aether/apidocs/overview-summary.html
+
+## Incomplete, seemingly often wrong
+https://docs.sonatype.org/display/AETHER/Home
+
+|#
(in-package :abcl-asdf)
@@ -26,15 +34,59 @@
"Locations to search for the Maven executable.")
(defun find-mvn ()
- "Attempt to find a suitable Maven ('mvn') executable on the hosting operating system."
- (dolist (mvn-path *mavens*)
- (let ((mvn
+ "Attempt to find a suitable Maven ('mvn') executable on the hosting operating system.
+
+Returns the path of the Maven executable or nil if none are found."
+
+ (when (and (asdf:getenv "M2_HOME") ;; TODO "anaphor" me!
+ (probe-file (asdf:getenv "M2_HOME")))
+ (let* ((m2-home (truename (asdf:getenv "M2_HOME")))
+ (mvn-executable (if (find :unix *features*)
+ "mvn"
+ "mvn.bat"))
+ (mvn-path (merge-pathnames
+ (format nil "bin/~A" mvn-executable)
+ m2-home))
+ (mvn (truename mvn-path)))
+ (if mvn
+ (return-from find-mvn mvn)
+ (warn "M2_HOME was set to '~A' in the process environment but '~A' doesn't exist."
+ m2-home mvn-path))))
+ (when (and (asdf:getenv "M2") ;; TODO "anaphor" me!
+ (probe-file (asdf:getenv "M2")))
+ (let* ((m2 (truename (asdf:getenv "M2")))
+ (mvn-executable (if (find :unix *features*)
+ "mvn"
+ "mvn.bat"))
+ (mvn-path (merge-pathnames mvn-executable m2))
+ (mvn (truename mvn-path)))
+ (if mvn
+ (return-from find-mvn mvn)
+ (warn "M2 was set to '~A' in the process environment but '~A' doesn't exist."
+ m2 mvn-path))))
+ (let* ((which-cmd
+ (if (find :unix *features*)
+ "which"
+ ;; Starting with Windows Server 2003
+ "where.exe"))
+ (which-cmd-p
(handler-case
- (truename (read-line (sys::process-output
- (sys::run-program "which" `(,mvn-path))))) ;; TODO equivalent for MSDOS
- (end-of-file () nil))))
- (when mvn
- (return-from find-mvn mvn)))))
+ (sys::run-program which-cmd nil)
+ (t () nil))))
+ (when which-cmd-p
+ (dolist (mvn-path *mavens*)
+ (let ((mvn
+ (handler-case
+ (truename (read-line (sys::process-output
+ (sys::run-program
+ which-cmd `(,mvn-path)))))
+ (end-of-file () nil)
+ (t (e)
+ (format *maven-verbose*
+ "~&Failed to find Maven executable '~A' in PATH because~&~A"
+ mvn-path e)))))
+ (when mvn
+ (return-from find-mvn mvn)))))))
(defun find-mvn-libs ()
(let ((mvn (find-mvn)))
More information about the armedbear-cvs
mailing list