summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2018-05-26 10:06:47 +0300
committerBozhidar Batsov <bozhidar@batsov.com>2018-05-26 10:08:32 +0300
commit717222c21bf075ba5f8c0fedba69e697c317f0d2 (patch)
tree4053f5515f28f6b91edd3869735d5681ff566d03
parente8ff30f180c0478c026a067b320c5026dc3e0c44 (diff)
Improve library checking
Now you can check for "group-id/artifact", which is more robust and solves our problem with "cemerick/piggieback" and "cider/piggieback".
-rw-r--r--cider-client.el24
-rw-r--r--cider.el12
2 files changed, 28 insertions, 8 deletions
diff --git a/cider-client.el b/cider-client.el
index df5b1431..38947444 100644
--- a/cider-client.el
+++ b/cider-client.el
@@ -812,9 +812,29 @@ going to clobber *1/2/3)."
t ; tooling
))
+;; TODO: Add some unit tests and pretty those two functions up.
+(defun cider-classpath-libs ()
+ "Return a list of all libs on the classpath."
+ (let ((libs (seq-filter (lambda (cp-entry)
+ (string-suffix-p ".jar" cp-entry))
+ (cider-sync-request:classpath))))
+ (thread-last libs
+ (seq-map (lambda (s) (split-string s "/")))
+ (seq-map #'reverse)
+ (seq-map (lambda (l) (reverse (seq-take l 4)))))))
+
(defun cider-library-present-p (lib)
- "Check whether LIB is present on the classpath."
- (seq-find (lambda (s) (string-match-p (concat lib ".*\\.jar") s)) (cider-sync-request:classpath)))
+ "Check whether LIB is present on the classpath.
+
+The library is a string of the format \"group-id/artifact-id\"."
+ (let* ((lib (split-string lib "/"))
+ (group-id (car lib))
+ (artifact-id (cadr lib)))
+ (seq-find (lambda (lib)
+ (let ((g (car lib))
+ (a (cadr lib)))
+ (and (equal group-id g) (equal artifact-id a))))
+ (cider-classpath-libs))))
(defalias 'cider-current-repl-buffer #'cider-current-connection
"The current REPL buffer.
diff --git a/cider.el b/cider.el
index 8351af95..6fd9a71b 100644
--- a/cider.el
+++ b/cider.el
@@ -623,12 +623,12 @@ Generally you should not disable this unless you run into some faulty check."
(defun cider-verify-clojurescript-is-present ()
"Check whether ClojureScript is present."
- (unless (cider-library-present-p "clojurescript")
+ (unless (cider-library-present-p "org.clojure/clojurescript")
(user-error "ClojureScript is not available. See http://cider.readthedocs.io/en/latest/clojurescript for details")))
(defun cider-verify-piggieback-is-present ()
"Check whether the piggieback middleware is present."
- (unless (cider-library-present-p "piggieback")
+ (unless (cider-library-present-p "cider/piggieback")
(user-error "Piggieback is not available. See http://cider.readthedocs.io/en/latest/clojurescript for details")))
(defun cider-check-nashorn-requirements ()
@@ -646,24 +646,24 @@ Generally you should not disable this unless you run into some faulty check."
(defun cider-check-figwheel-requirements ()
"Check whether we can start a Figwheel ClojureScript REPL."
(cider-verify-piggieback-is-present)
- (unless (cider-library-present-p "figwheel-sidecar")
+ (unless (cider-library-present-p "figwheel-sidecar/figwheel-sidecar")
(user-error "Figwheel-sidecar is not available. Please check http://cider.readthedocs.io/en/latest/clojurescript")))
(defun cider-check-weasel-requirements ()
"Check whether we can start a Weasel ClojureScript REPL."
(cider-verify-piggieback-is-present)
- (unless (cider-library-present-p "weasel")
+ (unless (cider-library-present-p "weasel/weasel")
(user-error "Weasel in not available. Please check http://cider.readthedocs.io/en/latest/clojurescript/#browser-connected-clojurescript-repl")))
(defun cider-check-boot-requirements ()
"Check whether we can start a Boot ClojureScript REPL."
(cider-verify-piggieback-is-present)
- (unless (cider-library-present-p "boot-cljs-repl")
+ (unless (cider-library-present-p "adzerk/boot-cljs-repl")
(user-error "The Boot ClojureScript REPL is not available. Please check https://github.com/adzerk-oss/boot-cljs-repl/blob/master/README.md")))
(defun cider-check-shadow-cljs-requirements ()
"Check whether we can start a shadow-cljs REPL."
- (unless (cider-library-present-p "shadow-cljs")
+ (unless (cider-library-present-p "thheller/shadow-cljs")
(user-error "The shadow-cljs ClojureScript REPL is not available")))
(defun cider-shadow-cljs-init-form ()