From 717222c21bf075ba5f8c0fedba69e697c317f0d2 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sat, 26 May 2018 10:06:47 +0300 Subject: 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". --- cider-client.el | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'cider-client.el') 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. -- cgit v1.2.3