Ignore:
Timestamp:
06/29/11 15:35:07 (10 years ago)
Author:
Mark Evenson
Message:

RESOLVE-DEPENDENCIES now working for remote resolution.

Something like

CL-USER> (require :abcl-asdf)
CL-USER> (abcl-asdf:resolve-dependencies "org.slf4j" "slf4j-api" "1.6.1")

should download the required dependencies for the corresponding Maven
artifact, returning the result as a string suitable for inclusion in
the CLASSPATH.

Abandoned strategy of using Maven Ant tasks to directly maniuplating
the Aether API in contemporary version of Maven 3.

Remove MVN package, folding symbols into ABCL-ASDF until clearer API
vision is in place as there is no need to complicate things at this
point.

The ASDF links are not currently working, nor is the ability to find
the Maven location under WIN32 as the resolution mechanism currently
uses UNIX 'which'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp

    r13345 r13367  
    11(defpackage #:abcl-asdf
    22  (:use :cl)
    3   (:export #:package))
     3  (:export
     4   #:satisfy
     5   #:as-classpath
    46
    5 
    6 (defpackage #:mvn
    7   (:use :cl)
    8   (:export #:satisfy
    9            #:as-classpath))
     7   #:resolve-artifact
     8   #:resolve-dependencies))
    109
    1110(in-package :asdf)
    12 (defclass iri (static-class) ())
     11(defclass iri (static-class)
     12  (schema authority path query fragment))
    1313
    1414(defclass mvn (iri) ())
     
    1717(defmethod perform ((op compile-op) (c mvn))
    1818    (let ((version (component-version c)))
    19       (mvn:satisfy (component-name c)
    20                    :version (if version version :latest))))
     19      (abcl-asdf:satisfy (component-name c)
     20                         :version (if version version :latest))))
    2121
    2222(defmethod perform ((operation load-op) (c mvn))
    2323    (let ((version (component-version c)))
    2424      (java:add-to-classpath
    25        (mvn:as-classpath
    26         (mvn:satisfy (component-name c)
     25       (abcl-asdf:as-classpath
     26        (abcl-asdf:satisfy (component-name c)
    2727                     :version (if version version :latest))))))
    2828
    29 (in-package :abcl-asdf)
    30 
    31 (defun decompose (iri)
    32   (declare (ignore iri))
    33   ;;; XXX test
    34   `((:scheme :jvm)
    35     (:authority :mvn)
    36     (:host "log4j")
    37     (:version "1.4.10")))
    38 
    39 (in-package :mvn)
    40 
    41 (defparameter *maven-ant-tasks.jar*
    42   "/export/home/evenson/src/apache-maven-3.0.3/maven-ant-tasks-2.1.1.jar")
    43 
    44 #|
    45 
    46 Ant with Maven tasks would add the following
    47 
    48   <artifact:dependencies pathId="abcl.dynamic.classpath">
    49     <dependency groupId="junit" artifactId="junit" version="3.8.2"/>
    50   </artifact:dependencies>
    51 |#
    52 
    53 (defvar *ant-build-template*
    54   (format nil
    55   "<?xml version='1.0' encoding='UTF-8'?>
    56 <project xmlns='antlib:org.apache.tools.ant'
    57          xmlns:artifact='antlib:org.apache.maven.artifact.ant'
    58          name='abcl-mvn-~A' default='install'>
    59 
    60   <artifact:dependencies pathId='abcl.dynamic.classpath'>
    61     <dependency groupId='~A' artifactId='~A' version='~A'/>
    62   </artifact:dependencies>
    63 
    64   <path id='abcl.jar'>
    65     <pathelement location='/export/home/evenson/work/abcl/dist/abcl.jar'/>
    66   </path>
    67 
    68   <target name='install'>
    69     <java classname='org.armedbear.lisp.Main'>
    70       <classpath refid='abcl.jar'>
    71       <classpath refid='abcl.dynamic.classpath'>
    72     </java>
    73   </target>
    74 </project>
    75 " (symbol-name (gensym)) "junit" "junit" "3.8.2"))
     29(in-package #:abcl-asdf)
    7630
    7731(defun satisfy (name &key (version :latest))
    78   (declare (ignore name version))
    79   (let ((build.xml (ext:make-temp-file)))
    80     (with-open-file (s build.xml :direction :output)
    81       (write-string *ant-build-template* s ))
    82     (ext:run-program
    83      (format nil "ant -find ~A -lib ~A"
    84              build.xml
    85              *maven-ant-tasks.jar*))))
    86 
    87 (defun as-classpath (mvn)
     32  (declare (ignore version))
     33  (resolve-dependencies name))
     34           
     35(defun as-classpath (classpath)
    8836  "For a given MVN entry, return a list of loadable archives
    8937 suitable for addition to the classpath."
    90   (declare (ignore mvn))
    91   (error "unimplemented"))
    92                        
     38  (split-string classpath ":"))
    9339
    94 
    95 
     40(defun split-string (string split-char)
     41  (loop :for i = 0 :then (1+ j)
     42     :as j = (position split-char string :test #'string-equal :start i)
     43     :collect (subseq string i j)
     44     :while j))
Note: See TracChangeset for help on using the changeset viewer.