Support multiple Maven repositories

(Olof-Joachim Frahm)

Necessary to easily get all dependencies for an artifact.

From <https://github.com/Ferada/abcl/commit/38f9806e5bde91bdccc21953a4437a46f717c54c>.
parent 9ab494ea
......@@ -14,7 +14,7 @@
(defclass mvn (iri)
((group-id :initarg :group-id :initform nil)
(artifact-id :initarg :artifact-id :initform nil)
(repository :initarg :repository :initform "http://repo1.maven.org/maven2/") ;;; XXX unimplemented
(repositories :initarg :repositories :initform nil)
(resolved-classpath :initform nil :accessor resolved-classpath)
(classname :initarg :classname :initform nil)
(alternate-uri :initarg :alternate-uri :initform nil)
......@@ -55,7 +55,7 @@
(defun ensure-parsed-mvn (component)
(with-slots (name group-id artifact-id
version schema path repository)
version schema path repositories)
component
(when (null asdf::artifact-id)
(let ((parsed (abcl-asdf::split-string name "/"))
......@@ -77,8 +77,8 @@
(error "Failed to construct a mvn reference from name '~A' and version '~A'"
name version)))
(setf schema "mvn")
(when repository
(pushnew repository *mvn-repositories*))
(when repositories
(setf *mvn-repositories* (union repositories *mvn-repositories* :test #'string=)))
;;; Always set path to normalized path "on the way out" to
;;; contain group-id/artifact-id/version
;;; TODO? record repository as well in path of component
......@@ -107,13 +107,13 @@ Returns either a string in jvm classpath format as entries delimited
by classpath separator string or T. If the value T is returned, it
denotes that current JVM already has already loaded a given class. Can possibly be a
single entry denoting a remote binary artifact."
(asdf:ensure-parsed-mvn mvn-component)
(asdf::ensure-parsed-mvn mvn-component)
(let ((name (slot-value mvn-component 'asdf::name))
(group-id (slot-value mvn-component 'asdf::group-id))
(artifact-id (slot-value mvn-component 'asdf::artifact-id))
(classname (slot-value mvn-component 'asdf::classname))
(alternate-uri (slot-value mvn-component 'asdf::alternate-uri))
(repository (slot-value mvn-component 'asdf::repository))
(repositories (slot-value mvn-component 'asdf::repositories))
(version (if (slot-value mvn-component 'asdf::version)
(slot-value mvn-component 'asdf::version)
"LATEST")))
......@@ -130,7 +130,7 @@ single entry denoting a remote binary artifact."
(if (find-mvn)
(resolve-dependencies group-id artifact-id
:version version
:repository repository)
:repositories repositories)
(if alternate-uri
(values (pathname alternate-uri) alternate-uri)
(error "Failed to resolve MVN component name ~A." name)))))
......
......@@ -507,7 +507,8 @@ Returns the Maven specific string for the artifact "
(defun resolve-dependencies (group-id artifact-id
&key
(version "LATEST" versionp)
(repository *maven-remote-repository* repository-p))
(repository *maven-remote-repository* repository-p)
(repositories NIL repositories-p))
"Dynamically resolve Maven dependencies for item with GROUP-ID and ARTIFACT-ID
optionally with a VERSION and a REPOSITORY.
......@@ -529,12 +530,16 @@ in Java CLASSPATH representation."
artifact (java:jfield (jss:find-java-class "JavaScopes") "COMPILE")))
(collect-request (java:jnew (jss:find-java-class "CollectRequest"))))
(#"setRoot" collect-request dependency)
;; Don't call addRepository if we explicitly specify a NIL repository
(unless (and repository-p (not repository))
(#"addRepository" collect-request
(if repository-p
(ensure-remote-repository :repository repository)
(ensure-remote-repository))))
(setf repositories-p (or repository-p repositories-p))
;; Don't call addRepository if we explicitly specify a NIL repository
(cond
((and (not repositories-p))
(#"addRepository" collect-request (ensure-remote-repository)))
(repository
(push repository repositories)))
(dolist (repository repositories)
(#"addRepository" collect-request
(ensure-remote-repository :repository repository)))
(let* ((node
(#"getRoot" (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request)))
(dependency-request
......
......@@ -30,8 +30,6 @@
#:*maven-http-proxy*
#:make-remote-repository
#:*maven-remote-repository*
#:resolve-artifact
#:resolve-dependencies
#:resolve-multiple-maven-dependencies
#:as-classpath
......
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 sign in to comment