# HG changeset patch
# Parent  1ce55192468b913fccc847edadcec2b9694a955a
Fix ABCL-ASDF usage with maven-3.3.x

Addresses <http://abcl.org/trac/ticket/390>.

diff -r 1ce55192468b contrib/abcl-asdf/maven-embedder.lisp
--- a/contrib/abcl-asdf/maven-embedder.lisp	Fri Jun 12 09:18:37 2015 +0000
+++ b/contrib/abcl-asdf/maven-embedder.lisp	Tue Jun 30 13:53:26 2015 +0200
@@ -182,6 +182,9 @@
 Set *MVN-LIBS-DIRECTORY* to an explicit value before running this
 function in order to bypass the dynamic introspection of the location
 of the mvn executable with an explicit value."
+  (when force
+    (setf *session* nil
+          *repository-system* nil))
   (unless (or force *mvn-libs-directory*)
     (setf *mvn-libs-directory* (find-mvn-libs)))
   (unless (and *mvn-libs-directory*
@@ -250,6 +253,8 @@
          (find-service-locator))
         (wagon-provider-class 
          (or
+          (ignore-errors ;; Maven-3.3.x
+            (jss:find-java-class 'connector.transport.TransporterFactory))
           (ignore-errors ;; Maven-3.2.5
             (jss:find-java-class 'org.eclipse.aether.transport.wagon.WagonProvider))
           (ignore-errors  ;; Maven-3.1.x 
@@ -280,10 +285,18 @@
             (jss:find-java-class 'aether.RepositorySystem))
           (ignore-errors
             (java:jclass "org.sonatype.aether.RepositorySystem")))))
-    (#"setServices" locator
-                    wagon-provider-class
-                    (java:jarray-from-list
-                     (list (make-wagon-provider))))
+
+    (if (equal wagon-provider-class (ignore-errors (jss:find-java-class 'TransporterFactory)))
+        ;;; Maven-3.3.3
+        (let ((wagon-transporter-factory (jss:new 'WagonTransporterFactory)))
+          (#"setWagonProvider" wagon-transporter-factory (make-wagon-provider))
+          (#"setServices" locator
+                          wagon-provider-class
+                          (java:jarray-from-list (list wagon-transporter-factory))))
+        (#"setServices" locator
+                        wagon-provider-class
+                        (java:jarray-from-list
+                         (list (make-wagon-provider)))))
     (#"addService" locator
                    repository-connector-factory-class
                    wagon-repository-connector-factory-class)
@@ -364,11 +377,11 @@
 
 (defun make-artifact (artifact-string)
   "Return an instance of aether.artifact.DefaultArtifact initialized from ARTIFACT-STRING." 
-  (or 
+  (or
    (ignore-errors
-     (jss:new "org.sonatype.aether.util.artifact.DefaultArtifact" artifact-string))
+     (jss:new 'aether.artifact.DefaultArtifact artifact-string))
    (ignore-errors
-     (jss:new 'aether.artifact.DefaultArtifact artifact-string))))
+     (jss:new "org.sonatype.aether.util.artifact.DefaultArtifact" artifact-string))))
 
 (defun make-artifact-request () 
   "Construct a new aether.resolution.ArtifactRequest."
@@ -453,21 +466,24 @@
           (make-artifact coords))
          (dependency 
           (java:jnew (jss:find-java-class 'aether.graph.Dependency)
-                     artifact (java:jfield (jss:find-java-class "JavaScopes") "RUNTIME")))
+                     artifact (java:jfield (jss:find-java-class "JavaScopes") "COMPILE")))
          (collect-request (java:jnew (jss:find-java-class "CollectRequest"))))
     (#"setRoot" collect-request dependency)
-    (when repository
-      (#"addRepository" collect-request 
-                        (if repository-p
-                            (ensure-remote-repository :repository repository)
-                            (ensure-remote-repository))))
+    (#"addRepository" collect-request 
+                      (if repository-p
+                          (ensure-remote-repository :repository repository)
+                          (ensure-remote-repository)))
     (let* ((node 
             (#"getRoot" (#"collectDependencies" (ensure-repository-system) (ensure-session) collect-request)))
-           (dependency-request 
+           (dependency-request
+            ;;; pre Maven-3.3.x
+            #+nil
             (java:jnew (jss:find-java-class "DependencyRequest")
-                       node java:+null+))
+                       node java:+null+)
+            (jss:new 'DependencyRequest))
            (nlg 
             (java:jnew (jss:find-java-class "PreorderNodeListGenerator"))))
+      (#"setRoot" dependency-request node)
       (#"resolveDependencies" (ensure-repository-system) (ensure-session) dependency-request)
       (#"accept" node nlg)
       (#"getClassPath" nlg))))
