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

5

6 7
(defpackage #:mvn
  (:use :cl)
8 9
  (:export #:satisfy
           #:as-classpath))
10 11 12 13 14 15 16

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

(defclass mvn (iri) ())

;;; We interpret compilation to ensure that load-op will succeed
17 18 19
(defmethod perform ((op compile-op) (c mvn))
    (let ((version (component-version c)))
      (mvn:satisfy (component-name c) 
20 21
                   :version (if version version :latest))))

22 23
(defmethod perform ((operation load-op) (c mvn))
    (let ((version (component-version c)))
24
      (java:add-to-classpath 
25 26 27 28 29
       (mvn:as-classpath 
        (mvn:satisfy (component-name c)
                     :version (if version version :latest))))))

(in-package :abcl-asdf)
30 31

(defun decompose (iri) 
32
  (declare (ignore iri))
33 34 35 36 37 38
  ;;; XXX test 
  `((:scheme :jvm)
    (:authority :mvn)
    (:host "log4j")
    (:version "1.4.10")))

39 40 41 42
(in-package :mvn)

(defparameter *maven-ant-tasks.jar*
  "/export/home/evenson/src/apache-maven-3.0.3/maven-ant-tasks-2.1.1.jar")
43 44 45 46 47 48 49 50 51 52 53 54 55 56

#|

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'
57
         xmlns:artifact='antlib:org.apache.maven.artifact.ant'
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
         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"))

77 78 79 80 81 82 83 84 85
(defun satisfy (name &key (version :latest))
  (declare (ignore name version))
  (let ((build.xml (ext:make-temp-file)))
    (with-open-file (s build.xml :direction :output)
      (write-string *ant-build-template* s ))
    (ext:run-program 
     (format nil "ant -find ~A -lib ~A" 
             build.xml
             *maven-ant-tasks.jar*))))
86

87 88 89 90 91 92
(defun as-classpath (mvn)
  "For a given MVN entry, return a list of loadable archives 
 suitable for addition to the classpath."
  (declare (ignore mvn))
  (error "unimplemented"))
                       
93 94 95