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.
parent aa266ae7
......@@ -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."
......
......@@ -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))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment