[armedbear-cvs] r13550 - in trunk/abcl/contrib/abcl-asdf: . tests

mevenson at common-lisp.net mevenson at common-lisp.net
Tue Aug 30 15:41:05 UTC 2011


Author: mevenson
Date: Tue Aug 30 08:41:04 2011
New Revision: 13550

Log:
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.

Added:
   trunk/abcl/contrib/abcl-asdf/packages.lisp
Modified:
   trunk/abcl/contrib/abcl-asdf/abcl-asdf.asd
   trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp
   trunk/abcl/contrib/abcl-asdf/tests/example.lisp
   trunk/abcl/contrib/abcl-asdf/tests/log4j.asd

Modified: trunk/abcl/contrib/abcl-asdf/abcl-asdf.asd
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/abcl-asdf.asd	Tue Aug 30 07:03:29 2011	(r13549)
+++ trunk/abcl/contrib/abcl-asdf/abcl-asdf.asd	Tue Aug 30 08:41:04 2011	(r13550)
@@ -3,12 +3,17 @@
 
 (defsystem :abcl-asdf
   :author "Mark Evenson"
-  :version "0.3.2"
-  :depends-on ("jss") 
+  :version "0.4.0"
+  :depends-on (jss)
   :components 
-  ((:module base :pathname "" :components
-	    ((:file "abcl-asdf")
+  ((:module packages :pathname "" 
+            :components
+            ((:file "packages")))
+   (:module base :pathname "" 
+            :components
+            ((:file "abcl-asdf")
              (:file "asdf-jar" 
                     :depends-on ("abcl-asdf"))
              (:file "maven-embedder" 
-                    :depends-on ("abcl-asdf" "asdf-jar"))))))
+                    :depends-on ("abcl-asdf" "asdf-jar")))
+            :depends-on (packages))))

Modified: trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp	Tue Aug 30 07:03:29 2011	(r13549)
+++ trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp	Tue Aug 30 08:41:04 2011	(r13550)
@@ -1,43 +1,60 @@
-(defpackage #:abcl-asdf
-  (:use :cl)
-  (:export 
-   #:satisfy
-   #:as-classpath
-
-   #:resolve-artifact
-   #:resolve-dependencies
-
-   #:add-directory-jars-to-class-path
-   #:need-to-add-directory-jar?
-   
-   #:*added-to-classpath*
-   #:*inhibit-add-to-classpath*))
-
 (in-package :asdf)
-(defclass iri (static-class) 
-  (schema authority path query fragment))
-
-(defclass mvn (iri) ())
+(defclass iri (component) 
+  ((schema :initform nil)
+   (authority :initform nil)
+   (path :initform nil)
+   (query :initform nil)
+   (fragment :initform nil)))
+
+(defclass mvn (iri) 
+  ((group-id :initform nil)
+   (artifact-id :initform nil)))
+
+#+nil
+(defmethod find-component ((component iri) path)
+  component)
 
 ;;; We interpret compilation to ensure that load-op will succeed
 (defmethod perform ((op compile-op) (c mvn))
-    (let ((version (component-version c)))
-      (abcl-asdf:satisfy (component-name c) 
-                         :version (if version version :latest))))
-
+  (maybe-parse-mvn c)
+  (abcl-asdf:satisfy c))
+     
 (defmethod perform ((operation load-op) (c mvn))
-    (let ((version (component-version c)))
-      (java:add-to-classpath 
-       (abcl-asdf:as-classpath 
-        (abcl-asdf:satisfy (component-name c)
-                     :version (if version version :latest))))))
+  (maybe-parse-mvn c)
+  (java:add-to-classpath 
+   (abcl-asdf:as-classpath 
+    (abcl-asdf:satisfy c)))))
+
+;;; A Maven URI has the form "mvn:group-id/artifact-id/version"
+;;;
+;;; Currently we "stuff" the group-id/artifact-id into the 'name' and
+;;; use the component 'version' for the version string.
+(defun maybe-parse-mvn (component)
+  (with-slots (asdf::name asdf::group-id asdf::artifact-id
+               asdf::version asdf::schema asdf::path) component
+    (when (null asdf::artifact-id) 
+      (let ((slash (search "/" name)))
+        (unless (and (integerp slash)
+                     asdf::version)
+          (error "Failed to construct a mvn reference from name '~A' and version '~A'"
+                 asdf::name asdf::version))
+        (setf asdf::group-id (subseq asdf::name 0 slash)
+              asdf::artifact-id (subseq asdf::name (1+ slash))
+              asdf::schema "mvn"
+              asdf::path (format nil "~A/~A" asdf::name asdf::version))))))
+
+(defmethod source-file-type ((component iri) (system system))
+  nil)
+
+(defmethod component-relative-pathname ((component iri))
+  nil)
 
 (in-package #:abcl-asdf)
 
-(defun satisfy (name &key (version :latest))
-  (declare (ignore version))
-  (resolve-dependencies name))
-           
+(defun satisfy (mvn-component)
+  (with-slots (asdf::group-id asdf::artifact-id asdf::version) mvn-component
+    (resolve-dependencies asdf::group-id asdf::artifact-id asdf::version)))
+
 (defun as-classpath (classpath)
   "For a given MVN entry, return a list of loadable archives 
  suitable for addition to the classpath."

Added: trunk/abcl/contrib/abcl-asdf/packages.lisp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/abcl/contrib/abcl-asdf/packages.lisp	Tue Aug 30 08:41:04 2011	(r13550)
@@ -0,0 +1,15 @@
+(defpackage #:abcl-asdf
+  (:use :cl)
+  (:export 
+   #:satisfy
+   #:as-classpath
+
+   #:resolve-artifact
+   #:resolve-dependencies
+
+   #:add-directory-jars-to-class-path
+   #:need-to-add-directory-jar?
+   
+   #:*added-to-classpath*
+   #:*inhibit-add-to-classpath*))
+

Modified: trunk/abcl/contrib/abcl-asdf/tests/example.lisp
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/tests/example.lisp	Tue Aug 30 07:03:29 2011	(r13549)
+++ trunk/abcl/contrib/abcl-asdf/tests/example.lisp	Tue Aug 30 08:41:04 2011	(r13550)
@@ -1,5 +1,5 @@
 (require :jss)
 
-(let ((logger (#"getLogger" 'Logger (symbol-name (gensym)))))
-  (#"log" logger "Kilroy wuz here."))
+(let ((logger (#"getLogger" 'log4j.Logger (symbol-name (gensym)))))
+  (#"trace" logger "Kilroy wuz here."))
 

Modified: trunk/abcl/contrib/abcl-asdf/tests/log4j.asd
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/tests/log4j.asd	Tue Aug 30 07:03:29 2011	(r13549)
+++ trunk/abcl/contrib/abcl-asdf/tests/log4j.asd	Tue Aug 30 08:41:04 2011	(r13550)
@@ -3,8 +3,10 @@
 
 (defsystem :log4j
   :components 
-  ((:mvn "log4j/log4j" :version "1.4.9")
-   (:module src :pathname "")
-   ((:file "example"))))
+  ((:module log4j.jar :components 
+            ((:mvn "log4j/log4j" :version "1.2.15")))
+   (:module source :pathname "" :components
+            ((:file "example"))
+            :depends-on (log4j.jar))))
 
   




More information about the armedbear-cvs mailing list