summaryrefslogtreecommitdiff
path: root/cider-client.el
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 /cider-client.el
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".
Diffstat (limited to 'cider-client.el')
-rw-r--r--cider-client.el24
1 files changed, 22 insertions, 2 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.