[armedbear-cvs] r14192 - in trunk/abcl/contrib: abcl-asdf mvn

mevenson at common-lisp.net mevenson at common-lisp.net
Sat Oct 13 09:12:37 UTC 2012


Author: mevenson
Date: Sat Oct 13 02:12:36 2012
New Revision: 14192

Log:
abcl-asdf:  special case handling for finding com.sun.jna.Native et. al.

Fallback to finding 'jna.jar' via Maven is to download it ourselves.

Undefined what having a URI in your classpath means to your local JVM
implementation.

Modified:
   trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp
   trunk/abcl/contrib/mvn/jna.asd

Modified: trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp
==============================================================================
--- trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp	Sat Oct 13 02:12:34 2012	(r14191)
+++ trunk/abcl/contrib/abcl-asdf/abcl-asdf.lisp	Sat Oct 13 02:12:36 2012	(r14192)
@@ -100,10 +100,20 @@
 (defmethod resolve ((mvn-component asdf::mvn))
   "Resolve all runtime dependencies of MVN-COMPONENT.
 
-Returns a string in JVM CLASSPATH format as entries delimited by classpath separator string."
-  
-  (with-slots (asdf::group-id asdf::artifact-id asdf::version) mvn-component
-    (resolve-dependencies asdf::group-id asdf::artifact-id asdf::version)))
+Returns a string in JVM CLASSPATH format as entries delimited by
+classpath separator string.  Can possibly be a single entry denoting a
+remote binary artifact."
+  (let ((name (asdf::component-name mvn-component)))
+    (if (find-mvn)
+        (with-slots (asdf::group-id asdf::artifact-id asdf::version) mvn-component
+          (resolve-dependencies asdf::group-id asdf::artifact-id asdf::version))
+        (cond 
+          ((string= name
+                    "net.java.dev.jna/jna/3.4.0"
+                    (let ((uri #p"http://repo1.maven.org/maven2/net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar"))
+                      (values (namestring uri) uri))))
+          (t 
+           (error "Failed to resolve MVN component name ~A." name))))))
 
 (defun as-classpath (classpath)
   "Break apart the JVM CLASSPATH string into a list of its consituents."

Modified: trunk/abcl/contrib/mvn/jna.asd
==============================================================================
--- trunk/abcl/contrib/mvn/jna.asd	Sat Oct 13 02:12:34 2012	(r14191)
+++ trunk/abcl/contrib/mvn/jna.asd	Sat Oct 13 02:12:36 2012	(r14192)
@@ -3,20 +3,30 @@
 ;;;; Need to have jna.jar present for CFFI to have a chance of working.
 (asdf:defsystem :jna 
     :version "3.4.0"
-    :defsystem-depends-on (jss abcl-asdf))
-;; FIXME:  install a better handler in abcl-asdf  :components ((:mvn "net.java.dev.jna/jna/3.4.0")))
+    :defsystem-depends-on (jss abcl-asdf)
+;; FIXME: 
+    :components ((:mvn "net.java.dev.jna/jna/3.4.0")))
 
-(defmethod asdf:perform :after ((o asdf:load-op) (c (eql (asdf:find-system :jna))))
+(in-package :asdf) 
+(defmethod perform :after ((o load-op) (c (eql (find-system :jna))))
   (when (jss:find-java-class "com.sun.jna.Native")
     (provide :jna)))
 
-(defmethod asdf:perform :before ((o asdf:load-op) (c (eql (asdf:find-system :jna))))
+;;; After ASDF performs COMPILE-OP, one expects that the JNA Java
+;;; classes can be instantiated.  If not, execute various loading strategies.
+(defmethod perform ((o compile-op) (c (eql (find-system :jna))))
   ;; Theoretically this should be the same thing as the MVN component.
+  (format *debug-io* "~&Attemping to locate jvm binary artifacts for JNA...~&")
   (handler-case 
-      (unless (jss:find-java-class "com.sun.jna.Native")
-        (unless (java:add-to-classpath (abcl-asdf:resolve "net.java.dev.jna:jna:3.4.0"))
-          (java:add-to-classpath "http://repo1.maven.org/maven2/net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar")))
+      (jss:find-java-class "com.sun.jna.Native")
+    (java:java-exception (e)
+      (unless 
+          (java:add-to-classpath (abcl-asdf:resolve "net.java.dev.jna:jna:3.4.0"))
+        (unless 
+            (java:add-to-classpath #p"http://repo1.maven.org/maven2/net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar")
+          (error "Failed to load jna-3.4.0.jar from the network via URI."))
+        (error "Failed to load jna.jar via ABCL-ASDF.")))
     (t (e) 
-      (error "Failed to resolve 'jna.jar' because~&~A." e))))
+      (error "Failed to resolve 'jna.jar' because~&~A.~&" e))))
 
                          




More information about the armedbear-cvs mailing list