Changeset 13550


Ignore:
Timestamp:
08/30/11 15:41:04 (6 years ago)
Author:
mevenson
Message:

Maven dependencies loaded via ASDF defintions.

If a Maven3 installation can be found via FIND-MVN, ASDF definitions
of the form

(:mvn "GROUP-ID/ARTIFACT-ID" :version "VERSION")

will be resolved at the ASDF system load time via the Maven Aether
resolution mechanism.

The log4j example wrapping now works.

N.b. this code seriously distorts some of the notions of ASDF which
really seems to depend on its components actually being resident on
the filesystem. This needs to be adressed ("blessed") via
consultation with ASDF developers to ensure that the path we are
choosing is reasonably future-proof.

Location:
trunk/abcl/contrib/abcl-asdf
Files:
1 added
4 edited

Legend:

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

    r13432 r13550  
    44(defsystem :abcl-asdf
    55  :author "Mark Evenson"
    6   :version "0.3.2"
    7   :depends-on ("jss")
     6  :version "0.4.0"
     7  :depends-on (jss)
    88  :components
    9   ((:module base :pathname "" :components
    10       ((:file "abcl-asdf")
     9  ((:module packages :pathname ""
     10            :components
     11            ((:file "packages")))
     12   (:module base :pathname ""
     13            :components
     14            ((:file "abcl-asdf")
    1115             (:file "asdf-jar"
    1216                    :depends-on ("abcl-asdf"))
    1317             (:file "maven-embedder"
    14                     :depends-on ("abcl-asdf" "asdf-jar"))))))
     18                    :depends-on ("abcl-asdf" "asdf-jar")))
     19            :depends-on (packages))))
  • trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp

    r13430 r13550  
    1 (defpackage #:abcl-asdf
    2   (:use :cl)
    3   (:export
    4    #:satisfy
    5    #:as-classpath
     1(in-package :asdf)
     2(defclass iri (component)
     3  ((schema :initform nil)
     4   (authority :initform nil)
     5   (path :initform nil)
     6   (query :initform nil)
     7   (fragment :initform nil)))
    68
    7    #:resolve-artifact
    8    #:resolve-dependencies
     9(defclass mvn (iri)
     10  ((group-id :initform nil)
     11   (artifact-id :initform nil)))
    912
    10    #:add-directory-jars-to-class-path
    11    #:need-to-add-directory-jar?
    12    
    13    #:*added-to-classpath*
    14    #:*inhibit-add-to-classpath*))
    15 
    16 (in-package :asdf)
    17 (defclass iri (static-class)
    18   (schema authority path query fragment))
    19 
    20 (defclass mvn (iri) ())
     13#+nil
     14(defmethod find-component ((component iri) path)
     15  component)
    2116
    2217;;; We interpret compilation to ensure that load-op will succeed
    2318(defmethod perform ((op compile-op) (c mvn))
    24     (let ((version (component-version c)))
    25       (abcl-asdf:satisfy (component-name c)
    26                          :version (if version version :latest))))
     19  (maybe-parse-mvn c)
     20  (abcl-asdf:satisfy c))
     21     
     22(defmethod perform ((operation load-op) (c mvn))
     23  (maybe-parse-mvn c)
     24  (java:add-to-classpath
     25   (abcl-asdf:as-classpath
     26    (abcl-asdf:satisfy c)))))
    2727
    28 (defmethod perform ((operation load-op) (c mvn))
    29     (let ((version (component-version c)))
    30       (java:add-to-classpath
    31        (abcl-asdf:as-classpath
    32         (abcl-asdf:satisfy (component-name c)
    33                      :version (if version version :latest))))))
     28;;; A Maven URI has the form "mvn:group-id/artifact-id/version"
     29;;;
     30;;; Currently we "stuff" the group-id/artifact-id into the 'name' and
     31;;; use the component 'version' for the version string.
     32(defun maybe-parse-mvn (component)
     33  (with-slots (asdf::name asdf::group-id asdf::artifact-id
     34               asdf::version asdf::schema asdf::path) component
     35    (when (null asdf::artifact-id)
     36      (let ((slash (search "/" name)))
     37        (unless (and (integerp slash)
     38                     asdf::version)
     39          (error "Failed to construct a mvn reference from name '~A' and version '~A'"
     40                 asdf::name asdf::version))
     41        (setf asdf::group-id (subseq asdf::name 0 slash)
     42              asdf::artifact-id (subseq asdf::name (1+ slash))
     43              asdf::schema "mvn"
     44              asdf::path (format nil "~A/~A" asdf::name asdf::version))))))
     45
     46(defmethod source-file-type ((component iri) (system system))
     47  nil)
     48
     49(defmethod component-relative-pathname ((component iri))
     50  nil)
    3451
    3552(in-package #:abcl-asdf)
    3653
    37 (defun satisfy (name &key (version :latest))
    38   (declare (ignore version))
    39   (resolve-dependencies name))
    40            
     54(defun satisfy (mvn-component)
     55  (with-slots (asdf::group-id asdf::artifact-id asdf::version) mvn-component
     56    (resolve-dependencies asdf::group-id asdf::artifact-id asdf::version)))
     57
    4158(defun as-classpath (classpath)
    4259  "For a given MVN entry, return a list of loadable archives
  • trunk/abcl/contrib/abcl-asdf/tests/example.lisp

    r13340 r13550  
    11(require :jss)
    22
    3 (let ((logger (#"getLogger" 'Logger (symbol-name (gensym)))))
    4   (#"log" logger "Kilroy wuz here."))
     3(let ((logger (#"getLogger" 'log4j.Logger (symbol-name (gensym)))))
     4  (#"trace" logger "Kilroy wuz here."))
    55
  • trunk/abcl/contrib/abcl-asdf/tests/log4j.asd

    r13354 r13550  
    44(defsystem :log4j
    55  :components
    6   ((:mvn "log4j/log4j" :version "1.4.9")
    7    (:module src :pathname "")
    8    ((:file "example"))))
     6  ((:module log4j.jar :components
     7            ((:mvn "log4j/log4j" :version "1.2.15")))
     8   (:module source :pathname "" :components
     9            ((:file "example"))
     10            :depends-on (log4j.jar))))
    911
    1012 
Note: See TracChangeset for help on using the changeset viewer.