Changeset 14574


Ignore:
Timestamp:
08/16/13 11:40:56 (4 years ago)
Author:
mevenson
Message:

abcl-asdf/1.3.0: updated to work with maven-3.1.0.

Big thanks to Anton Vodonosov for the initial patch.

The code in maven-embedder.lisp should now work for all versions of
Maven greater than 3.0.3.

Added MAKE-ARTIFACT and MAKE-ARTIFACT-REQUEST for creating the
correponding Aether objects.

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

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/abcl-asdf/README.markdown

    r14437 r14574  
    5454    uri-like resources to be encapsulated in the future.
    5555
    56 The MVN component should specifiy a [Maven URI][1] as its PATH.  A
     56The MVN component should specify a [Maven URI][1] as its PATH.  A
    5757Maven URI has the form "GROUP-ID/ARTIFACT-ID/VERSION" which specifies
    5858the dependency to be satisfied for this component by resolution
     
    165165   
    166166    Created: 2011-01-01
    167     Revised: 2013-03-20
     167    Revised: 2013-08-16
    168168   
  • trunk/abcl/contrib/abcl-asdf/abcl-asdf.asd

    r14540 r14574  
    33(asdf:defsystem :abcl-asdf
    44  :author "Mark Evenson"
    5   :version "1.2.0"
     5  :version "1.3.0"
    66  :description "<> asdf:defsystem <urn:abcl.org/release/1.3.0-dev/contrib/abcl-asdf#1.1.0>"
    77  :depends-on (jss)
  • trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp

    r14365 r14574  
    8686    component))
    8787
    88 (export `(mvn iri ensure-parsed-mvn
    89               group-id artifact-id version) 'asdf)
     88(export `(mvn iri ensure-parsed-mvn group-id artifact-id version)
     89  'asdf)
    9090
    9191(defmethod source-file-type ((component iri) (system system))
     
    132132             (error "Failed to resolve MVN component name ~A." name))))))
    133133
     134(defmethod resolve ((uri pathname))
     135  (warn "Unimplemented."))
     136
    134137(defun as-classpath (classpath)
    135138  "Break apart the JVM CLASSPATH string into a list of its consituents."
  • trunk/abcl/contrib/abcl-asdf/maven-embedder.lisp

    r14504 r14574  
    185185
    186186The implementation is specified as Lisp closures.  Currently, it only
    187 specializes the lookup() method if passed an 'http' role hint."
     187specializes the lookup() method if passed an 'http' or an 'https' role
     188hint."
    188189  (unless *init* (init))
    189190  (java:jinterface-implementation
    190    "org.sonatype.aether.connector.wagon.WagonProvider"
     191   (#"getName"
     192    (or
     193     (ignore-errors  ;; Maven 3.1.0+
     194       (jss:find-java-class 'aether.connector.wagon.WagonProvider))
     195     (ignore-errors  ;; Maven 3.0.x
     196      (jss:find-java-class 'org.sonatype.aether.connector.wagon.WagonProvider))))
    191197   "lookup"
    192198   (lambda (role-hint)
     
    204210
    205211(defun find-service-locator ()
    206   (handler-case
    207       (java:jnew "org.apache.maven.repository.internal.MavenServiceLocator") ;; maven-3.0.4
    208     (error ()
    209       (java:jnew "org.apache.maven.repository.internal.DefaultServiceLocator"))))
     212  (or
     213   (ignore-errors
     214     (#"newServiceLocator" 'org.apache.maven.repository.internal.MavenRepositorySystemUtils)) ;; maven-3.1.0
     215   (ignore-errors
     216      (java:jnew "org.apache.maven.repository.internal.MavenServiceLocator")) ;; maven-3.0.4
     217   (ignore-errors
     218     (java:jnew "org.apache.maven.repository.internal.DefaultServiceLocator"))
     219   (ignore-errors  ;; maven-3.1.0 using org.eclipse.aether...
     220     (jss:find-java-class 'aether.impl.DefaultServiceLocator))))
    210221
    211222(defun make-repository-system ()
     
    214225         (find-service-locator))
    215226        (wagon-provider-class
    216          (java:jclass "org.sonatype.aether.connector.wagon.WagonProvider"))
     227   (or
     228    (ignore-errors
     229      (java:jclass "org.sonatype.aether.connector.wagon.WagonProvider"))
     230    (ignore-errors  ;; Maven-3.1.x
     231      (jss:find-java-class 'aether.connector.wagon.WagonProvider))))
    217232        (wagon-repository-connector-factory-class
    218          (java:jclass "org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory"))
     233   (or
     234    (ignore-errors
     235      (java:jclass "org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory"))
     236    (ignore-errors
     237      (jss:find-java-class 'aether.connector.wagon.WagonRepositoryConnectorFactory))))
    219238        (repository-connector-factory-class
    220          (java:jclass "org.sonatype.aether.spi.connector.RepositoryConnectorFactory"))
     239   (or
     240    (ignore-errors
     241      (java:jclass "org.sonatype.aether.spi.connector.RepositoryConnectorFactory"))
     242    (ignore-errors
     243      (jss:find-java-class 'aether.spi.connector.RepositoryConnectorFactory))))
    221244        (repository-system-class
    222          (java:jclass "org.sonatype.aether.RepositorySystem")))
     245   (or
     246    (ignore-errors
     247      (java:jclass "org.sonatype.aether.RepositorySystem"))
     248    (ignore-errors
     249      (jss:find-java-class 'aether.RepositorySystem)))))
    223250    (#"setServices" locator
    224251                    wagon-provider-class
     
    233260       
    234261(defun make-session (repository-system)
    235   "Construct a new org.sonatype.aether.RepositorySystemSession from REPOSITORY-SYSTEM"
    236   (let ((session
    237          (java:jnew (jss:find-java-class "MavenRepositorySystemSession")))
     262  "Construct a new aether.RepositorySystemSession from the specified REPOSITORY-SYSTEM."
     263  (let ((session
     264   (or
     265    (ignore-errors (#"newSession" 'org.apache.maven.repository.internal.MavenRepositorySystemUtils))
     266    (ignore-errors (java:jnew (jss:find-java-class "MavenRepositorySystemSession")))))
    238267        (local-repository
    239268         (java:jnew (jss:find-java-class "LocalRepository")
     
    242271    (#"setLocalRepositoryManager"
    243272     session
    244      (#"newLocalRepositoryManager" repository-system
    245                                    local-repository))))
     273     (or
     274      (ignore-errors      ;; maven-3.1.0
     275  (#"newLocalRepositoryManager"
     276   repository-system session local-repository))
     277      (ignore-errors
     278  (#"newLocalRepositoryManager"
     279   repository-system local-repository))))))
    246280
    247281(defparameter *maven-http-proxy* nil
     
    249283
    250284(defun make-proxy ()
    251   "Return an org.sonatype.aether.repository.Proxy instance initialized from *MAVEN-HTTP-PROXY*."
     285  "Return an aether.repository.Proxy instance initialized from *MAVEN-HTTP-PROXY*."
    252286  (unless *maven-http-proxy*
    253287    (warn "No proxy specified in *MAVEN-HTTP-PROXY*")
     
    263297         ;; TODO allow specification of authentication
    264298         (authentication java:+null+))
    265     (jss:new 'org.sonatype.aether.repository.Proxy
    266              scheme host port authentication)))
     299    (or
     300     (ignore-errors
     301       (jss:new 'org.eclipse.aether.repository.Proxy
     302    scheme host port authentication))
     303     (ignore-errors
     304       (jss:new 'org.sonatype.aether.repository.Proxy
     305    scheme host port authentication)))))
    267306
    268307(defparameter *repository-system*  nil
    269   "The org.sonatype.aether.RepositorySystem used by the Maeven Aether connector.")
     308  "The aether.RepositorySystem used by the Maeven Aether connector.")
    270309(defun ensure-repository-system (&key (force nil))
    271310  (when (or force (not *repository-system*))
     
    291330    *session*)
    292331
     332(defun make-artifact (artifact-string)
     333  "Return an instance of aether.artifact.DefaultArtifact initialized from ARTIFACT-STRING."
     334  (or
     335   (ignore-errors
     336     (jss:new "org.sonatype.aether.util.artifact.DefaultArtifact" artifact-string))
     337   (ignore-errors
     338     (jss:new 'aether.artifact.DefaultArtifact artifact-string))))
     339
     340(defun make-artifact-request ()
     341  "Construct a new aether.resolution.ArtifactRequest."
     342  (or
     343   (ignore-errors
     344     (java:jnew (jss:find-java-class 'aether.resolution.ArtifactRequest)))
     345   (ignore-errors
     346     (java:jnew "org.sonatype.aether.resolution.ArtifactRequest"))))
     347
    293348;;; TODO change this to work on artifact strings like log4j:log4j:jar:1.2.16
    294349(defun resolve-artifact (group-id artifact-id &optional (version "LATEST" versionp))
     
    303358    (warn "Using LATEST for unspecified version."))
    304359  (unless *init* (init))
    305   (let* ((artifact-string (format nil "~A:~A:~A" group-id artifact-id version))
     360  (let* ((artifact-string
     361    (format nil "~A:~A:~A" group-id artifact-id version))
    306362         (artifact
    307           (jss:new "org.sonatype.aether.util.artifact.DefaultArtifact" artifact-string))
     363    (make-artifact artifact-string))
    308364         (artifact-request
    309           (java:jnew "org.sonatype.aether.resolution.ArtifactRequest")))
     365    (make-artifact-request)))
    310366    (#"setArtifact" artifact-request artifact)
    311367    (#"addRepository" artifact-request (ensure-remote-repository))
     
    315371
    316372(defun make-remote-repository (id type url)
    317   (jss:new 'aether.repository.RemoteRepository id type url))
     373  (or
     374   (ignore-errors
     375     (#"build" (jss:new "org.eclipse.aether.repository.RemoteRepository$Builder" id type url)))
     376   (ignore-errors
     377     (jss:new 'aether.repository.RemoteRepository id type url))))
    318378
    319379(defparameter *default-repository*
     
    338398  *maven-remote-repository*)
    339399
     400
    340401(defun resolve-dependencies (group-id artifact-id
    341402                             &optional  ;;; XXX Uggh.  Move to keywords when we get the moxie.
     
    354415  (unless versionp
    355416    (warn "Using LATEST for unspecified version."))
    356   (let* ((artifact
    357           (java:jnew (jss:find-java-class "aether.util.artifact.DefaultArtifact")
    358                      (format nil "~A:~A:~A"
    359                              group-id artifact-id version)))
     417  (let* ((coords
     418    (format nil "~A:~A:~A" group-id artifact-id (if versionp version "LATEST")))
     419   (artifact
     420    (make-artifact coords))
    360421         (dependency
    361           (java:jnew (jss:find-java-class "aether.graph.Dependency")
    362                      artifact (java:jfield (jss:find-java-class "JavaScopes") "RUNTIME")))
     422          (java:jnew (jss:find-java-class 'aether.graph.Dependency)
     423         artifact (java:jfield (jss:find-java-class "JavaScopes") "RUNTIME")))
    363424         (collect-request (java:jnew (jss:find-java-class "CollectRequest"))))
    364425    (#"setRoot" collect-request dependency)
     
    382443           (format *maven-verbose* "~&~A~%" (#"toString" e))))
    383444    (java:jinterface-implementation
    384      "org.sonatype.aether.RepositoryListener"
     445     (#"getName" (jss:find-java-class 'aether.RepositoryListener))
    385446     "artifactDeployed"
    386447     #'log
  • trunk/abcl/contrib/abcl-asdf/packages.lisp

    r14504 r14574  
    77   #:ensure-mvn-version
    88
    9 ;;; Leaning towards deprecation
    10    #:resolve-dependencies
    11    #:resolve-artifact
    12 
    139   #:find-mvn
    1410
     
    1713   #:init
    1814
    19 ;;; ASDF
    20 ;;;   #:iri #:mvn
    21 ;;;   #:ensure-parsed-mvn
    22 
    2315;;; "Internal" API
     16   #:resolve-dependencies
     17   #:resolve-artifact
    2418
    2519;;;; Maven
Note: See TracChangeset for help on using the changeset viewer.