[armedbear-cvs] r13904 - trunk/abcl/contrib/abcl-asdf
mevenson at common-lisp.net
mevenson at common-lisp.net
Sun Apr 1 20:39:18 UTC 2012
Author: mevenson
Date: Sun Apr 1 13:39:17 2012
New Revision: 13904
Log:
abcl-asdf: refactor interface.
ENSURE-REMOTE-REPOSITORY now takes a keyword to specify the remote
repository to create. RESOLVE-DEPENDENCIES should now use this
mechanism to specify the remote repository.
The ASDF syntax of adding a :repository doesn't seem to be working.
Modified:
trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp
trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp
Modified: trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp Sun Apr 1 12:15:39 2012 (r13903)
+++ trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp Sun Apr 1 13:39:17 2012 (r13904)
@@ -1,6 +1,7 @@
;;;; The ABCL specific overrides in ASDF.
;;;;
;;;; Done separate from asdf.lisp for stability.
+(require :asdf)
(in-package :asdf)
(defclass iri (component)
@@ -11,8 +12,8 @@
(fragment :initform nil)))
(defclass mvn (iri)
- ((group-id :initform nil)
- (artifact-id :initform nil)
+ ((group-id :initarg :group-id :initform nil)
+ (artifact-id :initarg :artifact-id :initform nil)
(repository :initform "http://repo1.maven.org/maven2/") ;;; XXX unimplmented
;; inherited from ASDF:COMPONENT ??? what are the CL semantics on overriding -- ME 2012-04-01
#+nil (version :initform nil)))
@@ -21,16 +22,17 @@
(defmethod find-component ((component iri) path)
component)
+
;;; We intercept compilation to ensure that load-op will succeed
(defmethod perform ((op compile-op) (c mvn))
- (ensure-parsed-mvn c)
- (abcl-asdf:resolve c))
+ (abcl-asdf:resolve
+ (ensure-parsed-mvn c)))
(defmethod perform ((operation load-op) (c mvn))
- (ensure-parsed-mvn c)
(java:add-to-classpath
(abcl-asdf:as-classpath
- (abcl-asdf:resolve c))))
+ (abcl-asdf:resolve
+ (ensure-parsed-mvn c)))))
;;; A Maven URI has the form "mvn:group-id/artifact-id/version"
;;;
@@ -45,6 +47,13 @@
(defparameter *mvn-repositories* nil
"A list of all Maven repositories encountered in the lifetime of this instance of the implementation.")
+#+nil
+(defmethod slot-missing ((class mvn) object slot-name operation &optional new-value)
+ (setf (slot-value object slot-name)
+ (if new-value
+ new-value
+ nil)))
+
(defun ensure-parsed-mvn (component)
(with-slots (name group-id artifact-id
version schema path repository)
@@ -71,7 +80,11 @@
(setf schema "mvn")
(pushnew repository *mvn-repositories*)
;;; Always normalized path "on the way out" to contain group-id/artifact-id/version
- (setf path (format nil "~A/~A/~A" group-id artifact-id version))))))
+ (setf path (format nil "~A/~A/~A" group-id artifact-id version))))
+ component))
+
+(export `(mvn iri ensure-parsed-mvn
+ group-id artifact-id version) 'asdf)
(defmethod source-file-type ((component iri) (system system))
nil)
Modified: trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp Sun Apr 1 12:15:39 2012 (r13903)
+++ trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp Sun Apr 1 13:39:17 2012 (r13904)
@@ -289,19 +289,30 @@
(defun make-remote-repository (id type url)
(jss:new 'aether.repository.RemoteRepository id type url))
+(defparameter *default-repository*
+ "http://repo1.maven.org/maven2/")
+
+(defun add-repository (repository)
+ (ensure-remote-repository :repository repository))
+
(defparameter *maven-remote-repository* nil
"The remote repository used by the Maven Aether embedder.")
-(defun ensure-remote-repository ()
+(defun ensure-remote-repository (&key repository *default-repository* repository-p)
(unless *init* (init))
- (unless *maven-remote-repository*
- (let ((r (make-remote-repository "central" "default" "http://repo1.maven.org/maven2/")))
+ (unless (or repository-p
+ *maven-remote-repository*)
+ (let ((r (make-remote-repository "central" "default" repository)))
(when *maven-http-proxy*
(#"setProxy" r (make-proxy)))
(setf *maven-remote-repository* r)))
*maven-remote-repository*)
-(defun resolve-dependencies (group-id artifact-id &optional (version "LATEST" versionp))
- "Dynamically resolve Maven dependencies for item with GROUP-ID and ARTIFACT-ID at VERSION.
+(defun resolve-dependencies (group-id artifact-id
+ &optional ;;; XXX Uggh. Move to keywords when we get the moxie.
+ (version "LATEST" versionp)
+ (repository *maven-remote-repository* repository-p))
+ "Dynamically resolve Maven dependencies for item with GROUP-ID and ARTIFACT-ID
+optionally with a VERSION and a REPOSITORY. Users of the function are advised
All recursive dependencies will be visited before resolution is successful.
@@ -321,7 +332,10 @@
artifact (java:jfield (jss:find-java-class "JavaScopes") "RUNTIME")))
(collect-request (java:jnew (jss:find-java-class "CollectRequest"))))
(#"setRoot" collect-request dependency)
- (#"addRepository" collect-request (ensure-remote-repository))
+ (#"addRepository" collect-request
+ (if repository-p
+ (ensure-remote-repository :repository repository)
+ (ensure-remote-repository)))
(let* ((node
(#"getRoot" (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request)))
(dependency-request
@@ -378,7 +392,7 @@
#'log)))
-(defmethod resolve ((string t))
+(defmethod resolve ((string string))
"Resolve a colon separated GROUP-ID:ARTIFACT-ID[:VERSION] reference to a Maven artifact.
Examples of artifact references: \"log4j:log4j:1.2.14\" for
@@ -389,6 +403,13 @@
artifact and all of its transitive dependencies."
(let ((result (split-string string ":")))
(cond
- ((<= 2 (length result) 3)
+ ((= (length result) 3)
+ (resolve-dependencies (first result) (second result) (third result)))
+ (t
(apply #'resolve-dependencies result)))))
+#+nil
+(defmethod resolve ((mvn asdf:mvn))
+ (with-slots (asdf::group-id asdf::artifact-id asdf::version)
+ (asdf:ensure-parsed-mvn mvn)
+ (resolve-dependencies (format nil "~A:~A:~A" asdf::group-id asdf::artifact-id asdf::version))))
More information about the armedbear-cvs
mailing list