Changeset 15017


Ignore:
Timestamp:
05/25/17 06:27:04 (7 months ago)
Author:
mevenson
Message:

Refactor out initialization pattern for Maven as WITH-AETHER to be
used by external consumers/manipulators of the Maven Aether libraries.

Unfinished, but can be used now to guarantee that ABCL-ASDF has
located Maven, which will be retrofitted compatible with current
usage.

TODO Introduce toplevel handler for finding Maven.

Location:
trunk/abcl
Files:
4 edited

Legend:

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

    r15010 r15017  
    11;;;; The ABCL specific overrides in ASDF. 
    22;;;;
    3 ;;;; Done separately from asdf.lisp for stability.
     3;;;; Extensions to ASDF for use by ABCL
    44(require :asdf)
    55(in-package :asdf)
     
    2121   ;; inherited from ASDF:COMPONENT ??? what are the CL semantics on overriding -- ME 2012-04-01
    2222   #+nil   (version :initform nil)))
    23 
    24 #+nil
    25 (defmethod find-component ((component iri) path)
    26   component)
    27 
    2823
    2924;;; We intercept compilation to ensure that load-op will succeed
  • trunk/abcl/contrib/abcl-asdf/maven.lisp

    r15010 r15017  
    11;;;; Use the Aether system in a localy installed Maven3 distribution to download
    22;;;; and install JVM artifact dependencies.
     3
     4;;; TODO refactor out aether.lisp
    35
    46#|
     
    111113(defun find-mvn-libs ()
    112114  (unless (find-mvn)
    113     (warn "Failed to find Maven executable to determine Aether library location."))
     115    (warn "Failed to find Maven executable to determine Aether library location.  Continuing anyways."))
    114116  (some
    115117   (lambda (d)
    116      (when (directory (merge-pathnames "maven-core*.jar" d))
     118     (when (and
     119            (pathnamep d)
     120            (directory (merge-pathnames "maven-core*.jar" d)))
    117121       (truename d)))
    118    (list (make-pathname :defaults (merge-pathnames "../lib/" (find-mvn))
    119                         :name nil :type nil)
     122   (list (ignore-errors
     123           (make-pathname :defaults (merge-pathnames "../lib/" (find-mvn))
     124                          :name nil :type nil))
    120125         (ignore-errors
    121126           (make-pathname :defaults (merge-pathnames "lib/" (mvn-home))
    122127                          :name nil :type nil))
    123128         ;; library location for homebrew maven package on OS X
    124          (make-pathname :defaults (merge-pathnames "../libexec/lib/" (find-mvn))
    125                         :name nil :type nil)
     129         (ignore-errors
     130           (make-pathname :defaults (merge-pathnames "../libexec/lib/" (find-mvn))
     131                          :name nil :type nil))
    126132         #p"/usr/local/share/java/maven3/lib/" ;; FreeBSD ports
    127133         #p"/usr/local/maven/lib/"))) ;; OpenBSD location suggested by Timo MyyrÀ
     
    185191              (let ((matcher (#"matcher" pattern line)))
    186192                (when (#"find" matcher)
    187                   (return-from mvn-home (uiop/pathname:ensure-directory-pathname (#"group" matcher 1)))))))))
     193                  (return-from mvn-home
     194                    (uiop/pathname:ensure-directory-pathname (#"group" matcher 1)))))))))
    188195    (subprocess-error (e)
    189196          (error "Failed to invoke Maven executable to introspect library locations: ~a." e))))
     
    204211     (list major minor patch))))
    205212
     213(define-condition no-aether-maven-libs (error)
     214  ((locations :initarg :locations
     215              :initform nil
     216              :reader locations))
     217  (:report (lambda (condition stream)
     218             (format stream "No Maven Aether libraries found locally in '~a'."
     219                     (locations condition)))))
     220             
    206221(defparameter *init* nil)
    207222 
     
    219234  (unless (and *mvn-libs-directory*
    220235               (probe-file *mvn-libs-directory*))
    221     (error "Please obtain and install maven-3.0.3 or later locally from <http://maven.apache.org/download.html>, then set ABCL-ASDF:*MVN-LIBS-DIRECTORY* to the directory containing maven-core-3.*.jar et. al."))
     236    ;; FIXME Remove warning; put message in restart
     237    (warn "Please obtain and install maven-3.0.3 or later locally from <http://maven.apache.org/download.html>, then set ABCL-ASDF:*MVN-LIBS-DIRECTORY* to the directory containing maven-core-3.*.jar et. al.")
     238    (error (make-condition 'abcl-asdf::no-aether-maven-libs
     239                           :locations (list *mvn-libs-directory*))))
    222240  (unless (ensure-mvn-version)
    223     (error "We need maven-3.0.3 or later."))  (add-directory-jars-to-class-path *mvn-libs-directory* nil)
    224     (setf *init* t))
     241    (error "We need maven-3.0.3 or later."))
     242  (add-directory-jars-to-class-path *mvn-libs-directory* nil)
     243  (setf *init* t))
     244
     245(defmacro with-aether ((&optional aether-directory) &body body)
     246  "Ensure that the code in BODY is executed with the Maven Aether libraries on the classpath."
     247  `(progn
     248     (declare (ignore aether-directory)) ;;; FIXME
     249     (unless abcl-asdf::*init*
     250       (abcl-asdf::init))
     251     ,@body))
    225252
    226253(defun find-http-wagon ()
     
    260287        (progn
    261288          (format cl:*load-verbose*
    262                   "~&; abcl-asdf; WagonProvider stub passed '~A' as a hint it couldn't satisfy.~%" role-hint)
     289                  "~&; abcl-asdf; WagonProvider stub passed '~A' as a hint it couldn't satisfy.~%"
     290                  role-hint)
    263291          java:+null+))))
    264292   "release"
     
    268296(defun find-service-locator ()
    269297  (or
    270    (ignore-errors
    271      (#"newServiceLocator" 'org.apache.maven.repository.internal.MavenRepositorySystemUtils)) ;; maven-3.1.0
    272    (ignore-errors
    273      (java:jnew "org.apache.maven.repository.internal.MavenServiceLocator")) ;; maven-3.0.4
     298   (ignore-errors
     299     ;; maven-3.1.0
     300     (#"newServiceLocator" 'org.apache.maven.repository.internal.MavenRepositorySystemUtils))
     301   (ignore-errors
     302     ;; maven-3.0.4
     303     (java:jnew "org.apache.maven.repository.internal.MavenServiceLocator"))
    274304   (ignore-errors
    275305     (java:jnew "org.apache.maven.repository.internal.DefaultServiceLocator"))
    276    (ignore-errors  ;; maven-3.1.0 using org.eclipse.aether...
     306   (ignore-errors
     307     ;; maven-3.1.0 using org.eclipse.aether...
    277308     (jss:find-java-class 'aether.impl.DefaultServiceLocator))))
    278309
     
    338369  (let ((session
    339370         (or
    340           (ignore-errors (#"newSession" 'org.apache.maven.repository.internal.MavenRepositorySystemUtils))
     371          (ignore-errors (#"newSession"
     372                          'org.apache.maven.repository.internal.MavenRepositorySystemUtils))
    341373          (ignore-errors (java:jnew (jss:find-java-class "MavenRepositorySystemSession")))))
    342374        (local-repository
     
    472504      (setf *maven-remote-repository* r)))
    473505  *maven-remote-repository*)
    474 
    475506
    476507(defun resolve-dependencies (group-id artifact-id
     
    564595     #'log)))
    565596
    566 
    567597(defmethod resolve ((string string))
    568598  "Resolve a colon separated GROUP-ID:ARTIFACT-ID[:VERSION] reference to a Maven artifact.
  • trunk/abcl/contrib/abcl-asdf/package.lisp

    r15010 r15017  
    99   #:resolve
    1010
     11
     12   ;; Configuring Maven
     13
     14   #:with-aether
     15
    1116   #:ensure-mvn-version
    12 
     17   
    1318   #:find-mvn
    1419
  • trunk/abcl/t/package.lisp

    r14987 r15017  
    77  (:use :cl :prove))
    88
     9(defpackage abcl/test/t/maven
     10  (:use :cl))
    911
     12
     13
Note: See TracChangeset for help on using the changeset viewer.