Changeset 13836


Ignore:
Timestamp:
01/31/12 17:24:52 (9 years ago)
Author:
Mark Evenson
Message:

abcl-asdf: Enable the specification of an http(s) proxy in ABCL-ASDF:*maven-http-proxy*.

ABCL-ASDF:*MAVEN-VERBOSE* now controls the stream to which the Maven
Aether repository system reports progress in resolving dependencies.
The logging messages could be presented in a perhaps slightly less verbose method.

Refactor the setting of various subsystem in special variables with
associated ENSURE-* methods.

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

Legend:

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

    r13807 r13836  
    3535    (unless mvn
    3636      (warn "Failed to find Maven3 libraries.")
    37       (return-from find-mvn-libs))
     37      (return-from find-mvn-libs nil))
    3838    (truename (make-pathname
    3939               :defaults (merge-pathnames "../lib/" mvn)
     
    146146     (#"newLocalRepositoryManager" repository-system local-repository))))
    147147
     148(defparameter *session* nil
     149  "Reference to the Maven RepositorySystemSession")
     150
     151(defparameter *maven-http-proxy* nil
     152  "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*)
     160
     161(defun make-proxy ()
     162  "Return an org.sonatype.aether.repository.Proxy instance initialized form *MAVEN-HTTP-PROXY*."
     163  (unless *maven-http-proxy*
     164    (warn "No proxy specified in *MAVEN-HTTP-PROXY*")
     165    (return-from make-proxy nil))
     166  (let* ((p (pathname *maven-http-proxy*))
     167         (scheme (sys::url-pathname-scheme p))
     168         (authority (sys::url-pathname-authority p))
     169         (host (if (search ":" authority)
     170                   (subseq authority 0 (search ":" authority))
     171                   authority))
     172         (port (when (search ":" authority)
     173                 (parse-integer (subseq authority (1+ (search ":" authority))))))
     174         ;; TODO allow specification of authentication
     175         (authentication java:+null+))
     176    (jss:new 'org.sonatype.aether.repository.Proxy
     177             scheme host port authentication)))
     178
     179(defun ensure-session ()
     180  "Ensure that the RepositorySystemSession has been created.
     181
     182If *MAVEN-HTTP-PROXY* is non-nil, parse its value as the http proxy."
     183  (unless *session*
     184    (ensure-repository-system)
     185    (setf *session* (new-session *repository-system*))
     186    (#"setRepositoryListener" *session* (make-repository-listener))
     187    (when *maven-http-proxy*
     188      (let ((proxy (make-proxy)))
     189        (#"add" (#"getProxySelector" *session*)
     190                proxy
     191                ;; A string specifying non proxy hosts, or null
     192                java:+null+))))
     193    *session*)
     194   
     195
    148196(defun resolve-artifact (group-id artifact-id &optional (version "LATEST" versionp))
    149197  "Directly resolve Maven dependencies for item with GROUP-ID and ARTIFACT-ID at VERSION, ignoring dependencies.
     
    175223    (#"resolveArtifact" system session artifact-request)))
    176224
     225(defparameter *aether-remote-repository* nil) ;;; TODO
     226
    177227(defun resolve-dependencies (group-id artifact-id &optional (version "LATEST" versionp))
    178228  "Dynamically resolve Maven dependencies for item with GROUP-ID and ARTIFACT-ID at VERSION.
     
    187237  (unless versionp
    188238    (warn "Using LATEST for unspecified version."))
    189   (let* ((system
    190           (repository-system))
    191         (session
    192           (new-session system))
    193          (artifact
     239  (let* ;;((system
     240        ;; (repository-system))
     241        ;; (session
     242        ;;  (new-session system))
     243         ((artifact
    194244          (java:jnew (jss:find-java-class "aether.util.artifact.DefaultArtifact")
    195245                     (format nil "~A:~A:~A"
     
    203253         (collect-request (java:jnew (jss:find-java-class "CollectRequest"))))
    204254    (#"setRoot" collect-request dependency)
     255    (when *maven-http-proxy*
     256      (#"setProxy" central (make-proxy)))
    205257    (#"addRepository" collect-request central)
    206258    (let* ((node
    207             (#"getRoot" (#"collectDependencies" system session collect-request)))
     259            (#"getRoot" (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request)))
    208260           (dependency-request
    209261            (java:jnew (jss:find-java-class "DependencyRequest")
     
    211263           (nlg
    212264            (java:jnew (jss:find-java-class "PreorderNodeListGenerator"))))
    213       (#"resolveDependencies" system session dependency-request)
     265      (#"resolveDependencies" (ensure-repository-system) (ensure-session) dependency-request)
    214266      (#"accept" node nlg)
    215267      (#"getClassPath" nlg))))
    216268
    217 
    218 
     269(defparameter *maven-verbose* t
     270  "Stream to send output from the Maven Aether subsystem to, or NIL to muffle output")
     271
     272(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)))))
    219295
    220296         
  • trunk/abcl/contrib/abcl-asdf/packages.lisp

    r13808 r13836  
    1515;;;; Maven
    1616   #:*mvn-libs-directory*
     17   #:*maven-http-proxy*
     18   #:*maven-verbose*
    1719
    1820   #:satisfy
Note: See TracChangeset for help on using the changeset viewer.