emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/cider 6f2d3ba53b 3/3: Merge pull request #3227 from ajober


From: ELPA Syncer
Subject: [nongnu] elpa/cider 6f2d3ba53b 3/3: Merge pull request #3227 from ajoberstar/gradle
Date: Sat, 30 Jul 2022 22:58:15 -0400 (EDT)

branch: elpa/cider
commit 6f2d3ba53b34f616ece595077b5e355a8d8fc3b8
Merge: f422665fb0 c2744a85f2
Author: vemv <vemv@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #3227 from ajoberstar/gradle
    
    Support the Gradle wrapper for jack-in
---
 CHANGELOG.md                                      |  3 +++
 cider.el                                          | 18 +++++++++++++++---
 doc/modules/ROOT/pages/basics/up_and_running.adoc |  6 +++---
 test/cider-tests.el                               | 17 +++++++++++++++++
 4 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 703a7c5926..88d73f8c6d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,11 +6,14 @@
 
 - [#3226](https://github.com/clojure-emacs/cider/pull/3226): Populate 
completions metadata, making it possible to change the style of completion via 
`completion-category-override` or `completion-category-defaults`.
 - [#2946](https://github.com/clojure-emacs/cider/issues/2946): Add custom var 
`cider-merge-sessions` to allow combining sessions in two different ways: 
Setting `cider-merge-sessions` to `'host` will merge all sessions associated 
with the same host within a project. Setting it to `'project` will combine all 
sessions of a project irrespective of their host.
+- Support Gradle jack-in via the Gradle wrapper, instead of just a globally 
installed `gradle` on the `PATH`.
 
 ## Changes
 
 * Upgrade injected `cider-nrepl` to 
[0.28.5](https://github.com/clojure-emacs/cider-nrepl/releases/tag/v0.28.5).
 * [#3200](https://github.com/clojure-emacs/cider/issues/3200): Improve 
cider-browse-ns interface to allow selective hiding of var types as well as 
grouping options.  Include private vars in result list.
+* Changed default `cider-gradle-command` to `./gradlew` to use the Gradle 
wrapper
+* Changed default `cider-gradle-global-options` to `""` (empty, formerly 
`--no-daemon`)
 
 ## 1.4.1 (2022-05-25)
 
diff --git a/cider.el b/cider.el
index 4614900476..2f65c98d10 100644
--- a/cider.el
+++ b/cider.el
@@ -189,14 +189,14 @@ By default we favor the project-specific shadow-cljs over 
the system-wide."
   :package-version '(cider . "0.17.0"))
 
 (defcustom cider-gradle-command
-  "gradle"
+  "./gradlew"
   "The command used to execute Gradle."
   :type 'string
   :safe #'stringp
   :package-version '(cider . "0.10.0"))
 
 (defcustom cider-gradle-global-options
-  "--no-daemon"
+  ""
   "Command line options used to execute Gradle (e.g.: -m for dry run)."
   :type 'string
   :safe #'stringp
@@ -352,7 +352,11 @@ Throws an error if PROJECT-TYPE is unknown."
     ('shadow-cljs (let ((parts (split-string cider-shadow-cljs-command)))
                     (when-let* ((command (cider--resolve-command (car parts))))
                       (mapconcat #'identity (cons command (cdr parts)) " "))))
-    ('gradle (cider--resolve-command cider-gradle-command))
+    ;; here we have to account for use of the Gradle wrapper which is
+    ;; a shell script within their project, so if they have a clearly
+    ;; relative path like "./gradlew" use locate file instead of checking
+    ;; the exec-path
+    ('gradle (cider--resolve-project-command cider-gradle-command))
     (_ (user-error "Unsupported project type `%S'" project-type))))
 
 (defun cider-jack-in-global-options (project-type)
@@ -1652,6 +1656,14 @@ assume the command is available."
                            (executable-find (concat command ".bat")))))
     (shell-quote-argument command)))
 
+(defun cider--resolve-project-command (command)
+  "Find COMMAND in project dir or exec path (see variable `exec-path').
+If COMMAND starts with ./ or ../ resolve relative to `clojure-project-dir',
+otherwise resolve via `cider--resolve-command'."
+  (if (string-match-p "\\`\\.\\{1,2\\}/" command)
+      (locate-file command (list (clojure-project-dir)) '("" ".bat") 
'executable)
+    (cider--resolve-command command)))
+
 (defcustom cider-connection-message-fn #'cider-random-words-of-inspiration
   "The function to use to generate the message displayed on connect.
 When set to nil no additional message will be displayed.  A good
diff --git a/doc/modules/ROOT/pages/basics/up_and_running.adoc 
b/doc/modules/ROOT/pages/basics/up_and_running.adoc
index 8b91749188..c435a5e151 100644
--- a/doc/modules/ROOT/pages/basics/up_and_running.adoc
+++ b/doc/modules/ROOT/pages/basics/up_and_running.adoc
@@ -175,9 +175,9 @@ wait`)
 
 ==== Gradle Options
 
-* `cider-gradle-command` - the name of the Gradle executable (`gradle` by 
default)
-* `cider-gradle-parameters`
-* `cider-gradle-global-options`
+* `cider-gradle-command` - the name of the Gradle executable (`./gradlew` by 
default)
+* `cider-gradle-parameters` - the Gradle arguments to invoke the repl task 
(`clojureRepl` by default)
+* `cider-gradle-global-options` - these are usually global options to gradle, 
such as `--no-daemon` or `--configuration-cache` (empty by default)
 
 ==== shadow-cljs
 
diff --git a/test/cider-tests.el b/test/cider-tests.el
index 7abb7b30a1..f661741897 100644
--- a/test/cider-tests.el
+++ b/test/cider-tests.el
@@ -525,6 +525,23 @@
               :to-equal
               "(do (require '[shadow.cljs.devtools.api :as shadow]) 
(shadow/watch :client-build) (shadow/watch :other-build) (shadow/nrepl-select 
:client-build))"))))
 
+(describe "cider--resolve-project-command"
+  (it "if command starts with ./ it resolves relative to clojure-project-dir"
+    (spy-on 'locate-file :and-return-value "/project/command")
+    (spy-on 'executable-find :and-return-value "/bin/command")
+    (expect (cider--resolve-project-command "./command")
+            :to-equal "/project/command"))
+  (it "if command starts with ../ it resolves relative to clojure-project-dir"
+    (spy-on 'locate-file :and-return-value "/project/command")
+    (spy-on 'executable-find :and-return-value "/bin/command")
+    (expect (cider--resolve-project-command "../command")
+            :to-equal "/project/command"))
+  (it "if command is bare it resolves against the exec-path"
+    (spy-on 'locate-file :and-return-value "/project/command")
+    (spy-on 'executable-find :and-return-value "/bin/command")
+    (expect (cider--resolve-project-command "command")
+            :to-equal "/bin/command")))
+
 (provide 'cider-tests)
 
 ;;; cider-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]