abcl-asdf.lisp 1.98 KB
Newer Older
1 2 3 4
(defpackage #:abcl-asdf
  (:use :cl)
  (:export #:package))

5 6 7 8
(defpackage #:mvn
  (:use :cl)
  (:export #:satisfy))

9
(in-package :abcl-asdf)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

(in-package :asdf)
(defclass iri (static-class) ())

(defclass mvn (iri) ())

;;; We interpret compilation to ensure that load-op will succeed
(defmethod perform ((operation compile-op) (component mvn))
    (let ((version (component-version mvn)))
      (mvn:satisfy (component-name mvn) 
                   :version (if version version :latest))))

(defmethod perform ((operation load-op) (component mvn))
    (let ((version (component-version mvn)))
      (java:add-to-classpath 
       (as-classpath (mvn:satisfy (component-name mvn)
                                  :version (if version version :latest))))))

(defun decompose (iri) 
  ;;; XXX test 
  `((:scheme :jvm)
    (:authority :mvn)
    (:host "log4j")
    (:version "1.4.10")))

(defun mvn:satisfy (name &key (version :latest))
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
  (let ((build.xml (make-temp-file)))
    (with-open-file (s build.xml :direction :output)
      (write-string *ant-build-template* s ))
    (run-program 
     (format nil "ant -find ~A" build.xml))))

#|

Ant with Maven tasks would add the following

  <artifact:dependencies pathId="abcl.dynamic.classpath">
    <dependency groupId="junit" artifactId="junit" version="3.8.2"/>
  </artifact:dependencies>
|#

(defvar *ant-build-template*
  (format nil
  "<?xml version='1.0' encoding='UTF-8'?>
<project xmlns='antlib:org.apache.tools.ant'
         name='abcl-mvn-~A' default='install'>

  <artifact:dependencies pathId='abcl.dynamic.classpath'>
    <dependency groupId='~A' artifactId='~A' version='~A'/>
  </artifact:dependencies>

  <path id='abcl.jar'> 
    <pathelement location='/export/home/evenson/work/abcl/dist/abcl.jar'/>
  </path>

  <target name='install'>
    <java classname='org.armedbear.lisp.Main'>
      <classpath refid='abcl.jar'>
      <classpath refid='abcl.dynamic.classpath'>
    </java>
  </target>
</project>
" (symbol-name (gensym)) "junit" "junit" "3.8.2"))