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.
parent 8e7a30b8
;;;; 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 "") ;;; 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)
;;; 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))
(ensure-parsed-mvn c)))
(defmethod perform ((operation load-op) (c mvn))
(ensure-parsed-mvn c)
(abcl-asdf:resolve c))))
(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.")
(defmethod slot-missing ((class mvn) object slot-name operation &optional new-value)
(setf (slot-value object slot-name)
(if new-value
(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))))
(export `(mvn iri ensure-parsed-mvn
group-id artifact-id version) 'asdf)
(defmethod source-file-type ((component iri) (system system))
......@@ -289,19 +289,30 @@ Returns the Maven specific string for the artifact "
(defun make-remote-repository (id type url)
(jss:new 'aether.repository.RemoteRepository id type url))
(defparameter *default-repository*
(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" "")))
(unless (or repository-p
(let ((r (make-remote-repository "central" "default" repository)))
(when *maven-http-proxy*
(#"setProxy" r (make-proxy)))
(setf *maven-remote-repository* r)))
(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 @@ in Java CLASSPATH representation."
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)
(let* ((node
(#"getRoot" (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request)))
......@@ -378,7 +392,7 @@ in Java CLASSPATH representation."
(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 @@ Returns a string containing the necessary classpath entries for this
artifact and all of its transitive dependencies."
(let ((result (split-string string ":")))
((<= 2 (length result) 3)
((= (length result) 3)
(resolve-dependencies (first result) (second result) (third result)))
(apply #'resolve-dependencies result)))))
(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))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment