Skip to content

Commit 944c07b

Browse files
authored
[Fix #3310] Add ability to use custom coordinates in jack-in-dependecies (#3313)
1 parent 97497ce commit 944c07b

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New features
66

77
- [#3262](https://github.com/clojure-emacs/cider/issues/3262): Add navigation functionality to `npfb` keys inside the data inspector's buffer.
8+
- [#3310](https://github.com/clojure-emacs/cider/issues/3310): Add ability to use custom coordinates in jack-in-dependecies
89

910
### Changes
1011

cider.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,15 @@ one used."
708708
;; `java.lang.IllegalArgumentException: Duplicate key [...]`:
709709
(cider--dedupe-deps)
710710
(seq-map (lambda (dep)
711-
(format "%s {:mvn/version \"%s\"}" (car dep) (cadr dep))))))
711+
(if (listp (cadr dep))
712+
(format "%s {%s}"
713+
(car dep)
714+
(seq-reduce
715+
(lambda (acc v)
716+
(concat acc (format " :%s \"%s\" " (car v) (cdr v))))
717+
(cadr dep)
718+
""))
719+
(format "%s {:mvn/version \"%s\"}" (car dep) (cadr dep)))))))
712720
(middleware (mapconcat
713721
(apply-partially #'format "%s")
714722
(cider-jack-in-normalized-nrepl-middlewares)

doc/modules/ROOT/pages/basics/up_and_running.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ Here's how you can modify the injected dependencies for `cider-jack-in-clj`:
8686
;; auto-inject version 1.0 of the library foo/bar
8787
(cider-add-to-alist 'cider-jack-in-dependencies
8888
"foo/bar" "1.0")
89+
;; if you want to have full control over the coordinate description set it as an alist
90+
;; auto-inject {:git/sha "6ae2b6f71773de7549d7f22759e8b09fec27f0d9" for library org.clojure/tools.deps
91+
;; :git/url "https://github.com/clojure/tools.deps/"}
92+
(cider-add-to-alist 'cider-jack-in-dependencies
93+
"org.clojure/tools.deps"
94+
'(("git/sha" . "6ae2b6f71773de7549d7f22759e8b09fec27f0d9")
95+
("git/url" . "https://github.com/clojure/tools.deps/")))
8996
----
9097

9198
IMPORTANT: Always use the fully qualified `group/artifact` (e.g. `re-frame/re-frame`) in these dependencies, since only Leiningen supports the bare `re-frame` syntax.

test/cider-tests.el

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,24 @@
506506
(deps '(("nrepl/nrepl" "0.9.0"))))
507507
(let ((cider-clojure-cli-aliases ":test"))
508508
(expect (cider-clojure-cli-jack-in-dependencies "-J-Djdk.attach.allowAttachSelf" nil deps)
509-
:to-equal expected))))))
509+
:to-equal expected))))
510+
(it "allows to specify git coordinate as cider-jack-in-dependency"
511+
(setq-local cider-jack-in-dependencies '(("org.clojure/tools.deps" (("git/sha" . "6ae2b6f71773de7549d7f22759e8b09fec27f0d9")
512+
("git/url" . "https://github.com/clojure/tools.deps/")))))
513+
(let ((expected (string-join '("clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version \"0.9.0\"} "
514+
"cider/cider-nrepl {:mvn/version \"0.28.5\"} "
515+
"org.clojure/tools.deps { :git/sha \"6ae2b6f71773de7549d7f22759e8b09fec27f0d9\" :git/url \"https://github.com/clojure/tools.deps/\" }} "
516+
":aliases {:cider/nrepl {:main-opts [\"-m\" \"nrepl.cmdline\" "
517+
"\"--middleware\" \"[cider.nrepl/cider-middleware]\"]}}}' -M:cider/nrepl")
518+
"")))
519+
(setq-local cider-allow-jack-in-without-project t)
520+
(setq-local cider-clojure-cli-command "clojure")
521+
(setq-local cider-inject-dependencies-at-jack-in t)
522+
(setq-local cider-clojure-cli-aliases nil)
523+
(spy-on 'cider-project-type :and-return-value 'clojure-cli)
524+
(spy-on 'cider-jack-in-resolve-command :and-return-value "clojure")
525+
(expect (plist-get (cider--update-jack-in-cmd nil) :jack-in-cmd)
526+
:to-equal expected)))))
510527

511528
(defmacro with-temp-shadow-config (contents &rest body)
512529
"Run BODY with a mocked shadow-cljs.edn project file with the CONTENTS."

0 commit comments

Comments
 (0)