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.
parent d7862cda
......@@ -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))))
(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 iri (component)
((schema :initform nil)
(authority :initform nil)
(path :initform nil)
(query :initform nil)
(fragment :initform nil)))
(defclass mvn (iri) ())
(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."
......
(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*))
(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."))
......@@ -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))))
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