source: branches/0.27.x/abcl/contrib/abcl-asdf/abcl-asdf.lisp

Last change on this file was 13571, checked in by Mark Evenson, 14 years ago

Backport r13570: Fix typo in abcl-asdf.

File size: 2.2 KB
Line 
1(in-package :asdf)
2(defclass iri (component) 
3  ((schema :initform nil)
4   (authority :initform nil)
5   (path :initform nil)
6   (query :initform nil)
7   (fragment :initform nil)))
8
9(defclass mvn (iri) 
10  ((group-id :initform nil)
11   (artifact-id :initform nil)))
12
13#+nil
14(defmethod find-component ((component iri) path)
15  component)
16
17;;; We interpret compilation to ensure that load-op will succeed
18(defmethod perform ((op compile-op) (c mvn))
19  (maybe-parse-mvn c)
20  (abcl-asdf:satisfy c))
21     
22(defmethod perform ((operation load-op) (c mvn))
23  (maybe-parse-mvn c)
24  (java:add-to-classpath 
25   (abcl-asdf:as-classpath 
26    (abcl-asdf:satisfy c))))
27
28;;; A Maven URI has the form "mvn:group-id/artifact-id/version"
29;;;
30;;; Currently we "stuff" the group-id/artifact-id into the 'name' and
31;;; use the component 'version' for the version string.
32(defun maybe-parse-mvn (component)
33  (with-slots (asdf::name asdf::group-id asdf::artifact-id
34               asdf::version asdf::schema asdf::path) component
35    (when (null asdf::artifact-id) 
36      (let ((slash (search "/" name)))
37        (unless (and (integerp slash)
38                     asdf::version)
39          (error "Failed to construct a mvn reference from name '~A' and version '~A'"
40                 asdf::name asdf::version))
41        (setf asdf::group-id (subseq asdf::name 0 slash)
42              asdf::artifact-id (subseq asdf::name (1+ slash))
43              asdf::schema "mvn"
44              asdf::path (format nil "~A/~A" asdf::name asdf::version))))))
45
46(defmethod source-file-type ((component iri) (system system))
47  nil)
48
49(defmethod component-relative-pathname ((component iri))
50  nil)
51
52(in-package #:abcl-asdf)
53
54(defun satisfy (mvn-component)
55  (with-slots (asdf::group-id asdf::artifact-id asdf::version) mvn-component
56    (resolve-dependencies asdf::group-id asdf::artifact-id asdf::version)))
57
58(defun as-classpath (classpath)
59  "For a given MVN entry, return a list of loadable archives
60 suitable for addition to the classpath."
61  (split-string classpath ":"))
62
63(defun split-string (string split-char)
64  (loop :for i = 0 :then (1+ j)
65     :as j = (position split-char string :test #'string-equal :start i)
66     :collect (subseq string i j)
67     :while j))
Note: See TracBrowser for help on using the repository browser.