Changeset 13841


Ignore:
Timestamp:
02/01/12 13:25:05 (9 years ago)
Author:
Mark Evenson
Message:

abcl-asdf: Use *maven-http-proxy* for all Maven Aether resolutions.

Increment abcl-asdf ASDF version to 0.6.0 to denote the ability to
specify an http proxy for Maven.

Location:
trunk/abcl/contrib/abcl-asdf
Files:
3 edited

Legend:

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

    r13808 r13841  
    44(defsystem :abcl-asdf
    55  :author "Mark Evenson"
    6   :version "0.5.0"
     6  :version "0.6.0"
    77  :depends-on (jss)
    88  :components
  • trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp

    r13836 r13841  
    1 ;;; Use the Aether system in a default maven distribution to download
     1;;; Use the Aether system in a default Maven3 distribution to download
    22;;; and install dependencies.
    33;;;
    4 ;;; https://docs.sonatype.org/display/AETHER/Home
    5 ;;;
     4;;; References:
     5;;; -- javadoc
     6;;; http://sonatype.github.com/sonatype-aether/apidocs/overview-summary.html
     7;;; -- incomplete, seemingly often wrong
     8;;; https://docs.sonatype.org/display/AETHER/Home
    69
    710(in-package :abcl-asdf)
     
    1720|#
    1821
    19 (defvar *mavens* '("/opt/local/bin/mvn3" "mvn3" "mvn" "mvn.bat")
     22(defparameter *maven-verbose* t
     23  "Stream to send output from the Maven Aether subsystem to, or NIL to muffle output")
     24
     25(defvar *mavens* '("/opt/local/bin/mvn3" "mvn3" "mvn" "mvn3.bat" "mvn.bat")
    2026  "Locations to search for the Maven executable.")
    2127
     
    2632           (handler-case
    2733               (truename (read-line (sys::process-output
    28                                      (sys::run-program "which" `(,mvn-path)))))
     34                                     (sys::run-program "which" `(,mvn-path))))) ;; TODO equivalent for MSDOS
    2935             (end-of-file () nil))))
    3036      (when mvn
     
    4551
    4652(defun mvn-version ()
     53  "Return the Maven version used by the Aether connector."
    4754  (let* ((line
    4855         (read-line (sys::process-output
     
    7683(defparameter *init* nil)
    7784
    78 (defun init ()
     85(defun init (&optional &key (force nil))
    7986  "Run the initialization strategy to bootstrap a Maven dependency node."
    80   (unless *mvn-libs-directory*
     87  (unless (or force *mvn-libs-directory*)
    8188    (setf *mvn-libs-directory* (find-mvn-libs)))
    8289  (unless (probe-file *mvn-libs-directory*)
     
    111118     (declare (ignore wagon)))))
    112119
    113 (defun repository-system ()
     120(defun make-repository-system ()
    114121  (unless *init* (init))
    115122  (let ((locator
     
    135142                   repository-system-class)))
    136143       
    137 (defun new-session (repository-system)
     144(defun make-session (repository-system)
     145  "Construct a new org.sonatype.aether.RepositorySystemSession from REPOSITORY-SYSTEM"
    138146  (let ((session
    139147         (java:jnew (jss:find-java-class "MavenRepositorySystemSession")))
     
    146154     (#"newLocalRepositoryManager" repository-system local-repository))))
    147155
    148 (defparameter *session* nil
    149   "Reference to the Maven RepositorySystemSession")
    150 
    151156(defparameter *maven-http-proxy* nil
    152157  "A string containing the URI of an http proxy for Maven to use.")
    153 
    154 (defparameter *repository-system* nil)
    155 
    156 (defun ensure-repository-system ()
    157   (unless *repository-system*
    158     (setf *repository-system* (repository-system)))
    159   *repository-system*)
    160158
    161159(defun make-proxy ()
     
    177175             scheme host port authentication)))
    178176
     177(defparameter *repository-system*  nil
     178  "The org.sonatype.aether.RepositorySystem used by the Maeven Aether connector.")
     179(defun ensure-repository-system ()
     180  (unless *repository-system*
     181    (setf *repository-system* (make-repository-system)))
     182  *repository-system*)
     183
     184(defparameter *session* nil
     185  "Reference to the Maven RepositorySystemSession")
    179186(defun ensure-session ()
    180187  "Ensure that the RepositorySystemSession has been created.
     
    183190  (unless *session*
    184191    (ensure-repository-system)
    185     (setf *session* (new-session *repository-system*))
     192    (setf *session* (make-session *repository-system*))
    186193    (#"setRepositoryListener" *session* (make-repository-listener))
    187194    (when *maven-http-proxy*
     
    192199                java:+null+))))
    193200    *session*)
    194    
    195 
     201
     202;;; TODO change this to work on artifact strings like log4j:log4j:jar:1.2.16
    196203(defun resolve-artifact (group-id artifact-id &optional (version "LATEST" versionp))
    197204  "Directly resolve Maven dependencies for item with GROUP-ID and ARTIFACT-ID at VERSION, ignoring dependencies.
     
    201208If unspecified, the string \"LATEST\" will be used for the VERSION.
    202209
    203 Returns a string containing the necessary jvm classpath entries packed
    204 in Java CLASSPATH representation."
    205 
     210Returns the Maven specific string for the artifact "
    206211  (unless versionp
    207212    (warn "Using LATEST for unspecified version."))
    208   (let* ((system
    209           (repository-system))
    210          (session
    211           (new-session system))
    212          (repository
    213           (jss:new "org.sonatype.aether.repository.RemoteRepository"
    214                    "central" "default" "http://repo1.maven.org/maven2/"))
    215          (artifact-string (format nil "~A:~A:~A"
    216                                   group-id artifact-id version))
     213  (unless *init* (init))
     214  (let* ((artifact-string (format nil "~A:~A:~A" group-id artifact-id version))
    217215         (artifact
    218216          (jss:new "org.sonatype.aether.util.artifact.DefaultArtifact" artifact-string))
     
    220218          (java:jnew "org.sonatype.aether.resolution.ArtifactRequest")))
    221219    (#"setArtifact" artifact-request artifact)
    222     (#"addRepository" artifact-request repository)
    223     (#"resolveArtifact" system session artifact-request)))
    224 
    225 (defparameter *aether-remote-repository* nil) ;;; TODO
     220    (#"addRepository" artifact-request (ensure-remote-repository))
     221    (#"toString" (#"resolveArtifact" (ensure-repository-system) (ensure-session) artifact-request))))
     222
     223(defun make-remote-repository (id type url)
     224  (jss:new 'aether.repository.RemoteRepository id type url))
     225
     226(defparameter *maven-remote-repository*  nil
     227    "The remote repository used by the Maven Aether embedder.")
     228(defun ensure-remote-repository ()
     229  (unless *init* (init))
     230  (unless *maven-remote-repository*
     231    (let ((r (make-remote-repository "central" "default" "http://repo1.maven.org/maven2/")))
     232      (when *maven-http-proxy*
     233        (#"setProxy" r (make-proxy)))
     234      (setf *maven-remote-repository* r)))
     235  *maven-remote-repository*)
    226236
    227237(defun resolve-dependencies (group-id artifact-id &optional (version "LATEST" versionp))
     
    237247  (unless versionp
    238248    (warn "Using LATEST for unspecified version."))
    239   (let* ;;((system
    240         ;; (repository-system))
    241         ;; (session
    242         ;;  (new-session system))
    243          ((artifact
     249  (let* ((artifact
    244250          (java:jnew (jss:find-java-class "aether.util.artifact.DefaultArtifact")
    245251                     (format nil "~A:~A:~A"
     
    248254          (java:jnew (jss:find-java-class "aether.graph.Dependency")
    249255                     artifact "compile"))
    250          (central
    251           (java:jnew (jss:find-java-class "RemoteRepository")
    252                      "central" "default" "http://repo1.maven.org/maven2/"))
    253256         (collect-request (java:jnew (jss:find-java-class "CollectRequest"))))
    254257    (#"setRoot" collect-request dependency)
    255     (when *maven-http-proxy*
    256       (#"setProxy" central (make-proxy)))
    257     (#"addRepository" collect-request central)
     258    (#"addRepository" collect-request (ensure-remote-repository))
    258259    (let* ((node
    259260            (#"getRoot" (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request)))
     
    267268      (#"getClassPath" nlg))))
    268269
    269 (defparameter *maven-verbose* t
    270   "Stream to send output from the Maven Aether subsystem to, or NIL to muffle output")
    271 
    272270(defun make-repository-listener ()
    273   ;;; XXX why does the (flet ((log (e) ...)) (java:jinterface-implementation ...) version not work?
    274   (java:jinterface-implementation
    275    "org.sonatype.aether.RepositoryListener"
    276    "artifactDeployed" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    277    "artifactDeploying" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    278    "artifactDescriptorInvalid" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    279    "artifactDescriptorMissing" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    280    "artifactDownloaded" (lambda (e) (format *maven-verbose*  "~&transfer-listener: ~A~%" (#"toString" e)))
    281    "artifactDownloading" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    282    "artifactInstalled" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    283    "artifactInstalling" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    284    "artifactResolved" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    285    "artifactResolving" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    286    "metadataDeployed" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    287    "metadataDeploying" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    288    "metadataDownloaded" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    289    "metadataDownloading" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    290    "metadataInstalled" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    291    "metadataInstalling" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    292    "metadataInvalid" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    293    "metadataResolved" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))
    294    "metadataResolving" (lambda (e) (format *maven-verbose* "~&transfer-listener: ~A~%" (#"toString" e)))))
     271  (flet ((log (e)
     272           (format *maven-verbose* "~&~A~%" (#"toString" e))))
     273    (java:jinterface-implementation
     274     "org.sonatype.aether.RepositoryListener"
     275     "artifactDeployed"
     276     #'log
     277     "artifactDeploying"
     278     #'log
     279     "artifactDescriptorInvalid"
     280     #'log
     281     "artifactDescriptorMissing"
     282     #'log
     283     "artifactDownloaded"
     284     #'log
     285     "artifactDownloading"
     286     #'log
     287     "artifactInstalled"
     288     #'log
     289     "artifactInstalling"
     290     #'log
     291     "artifactResolved"
     292     #'log
     293     "artifactResolving"
     294     #'log
     295     "metadataDeployed"
     296     #'log
     297     "metadataDeploying"
     298     #'log
     299     "metadataDownloaded"
     300     #'log
     301     "metadataDownloading"
     302     #'log
     303     "metadataInstalled"
     304     #'log
     305     "metadataInstalling"
     306     #'log
     307     "metadataInvalid"
     308     #'log
     309     "metadataResolved"
     310     #'log
     311     "metadataResolving"
     312     #'log)))
    295313
    296314         
  • trunk/abcl/contrib/abcl-asdf/packages.lisp

    r13836 r13841  
    1616   #:*mvn-libs-directory*
    1717   #:*maven-http-proxy*
     18   #:make-remote-repository
     19   #:*maven-remote-repository*
    1820   #:*maven-verbose*
     21
     22   #:resolve-artifact
     23   #:resolve-dependencies
    1924
    2025   #:satisfy
    2126   #:as-classpath
    22 
    23    #:resolve-artifact
    2427
    2528   #:add-directory-jars-to-class-path
Note: See TracChangeset for help on using the changeset viewer.