Skip to content

Commit

Permalink
[ultra] Require nrepl or clojure.tools.nrepl dynamically
Browse files Browse the repository at this point in the history
clojure.tools.nrepl is now officially deprecated and has been replaced
with nrepl/nrepl. This commit updates all direct references to
clojure.tools.nrepl to use a dynamic import that checks to see if
clojure.tools.nrepl is on the path and otherwise to use the new nrepl.

As we rely on a significant amount of functionality in Whidbey/Puget,
those will also need to have their references updated.
  • Loading branch information
David Jarvis committed Dec 14, 2018
1 parent 31b9857 commit cfd4cf4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 0.6.0
* Migrates to `nrepl` from `clojure.tools.nrepl`

## 0.5.3
* Removes logical expression hints, they could cause double evaluation in test.
* Removes logical expression hints, they could cause double evaluation in test.

## 0.5.2
* Changed the printing behavior of test results to flush test output at the end of the test, making output clearer in cases where multi-threaded tests print to *out*
Expand Down Expand Up @@ -39,7 +42,7 @@
* Remove an embarrassing println statement

## 0.3.1
* Fix test initialization to be an injection that triggers a hook.
* Fix test initialization to be an injection that triggers a hook.

## 0.3.0
* Avoids initialization of unused features.
Expand All @@ -52,7 +55,7 @@
* Modifies the loading of the nREPL middleware to play nicely with CIDER.

## 0.2.0
* Moves Java function injection to be a hook sitting on clojure.tools.nrepl.server/start-server, which is a total hack but it seems to actually work, unlike literally everything else I've tried.
* Moves Java function injection to be a hook sitting on clojure.tools.nrepl.server/start-server, which is a total hack but it seems to actually work, unlike literally everything else I've tried.
* Removes Vinyasa dependency.
* Moving test activation from a defonce, which seemed to screw up Kibit.
* General cleanup and refactoring.
Expand Down
13 changes: 6 additions & 7 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
(defproject venantius/ultra "0.5.3"
(defproject venantius/ultra "0.6.0-SNAPSHOT"
:description "Ultra: A Leiningen plugin for a superior development environment"
:url "http://github.com/venantius/ultra"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/tools.nrepl "0.2.12"]

:dependencies [[nrepl "0.4.0"]
[grimradical/clj-semver "0.3.0" :exclusions [org.clojure/clojure]]
[io.aviso/pretty "0.1.30"]
[mvxcvi/whidbey "1.3.0"]
[mvxcvi/puget "1.0.1"]
[io.aviso/pretty "0.1.35"]
[mvxcvi/whidbey "1.3.2"]
[mvxcvi/puget "1.0.3"]
[org.clojars.brenton/google-diff-match-patch "0.1"]
[robert/hooke "1.3.0"]
[venantius/glow "0.1.4" :exclusions [hiccup garden]]]
[venantius/glow "0.1.5" :exclusions [hiccup garden]]]
:profiles {:dev {:dependencies [[circleci/bond "0.2.9"]
[org.clojure/clojure "1.8.0"]]}}
:test-selectors {:default (complement :demo)
Expand Down
10 changes: 8 additions & 2 deletions src/ultra/hardcore.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
(ns ultra.hardcore
"See what I did there?"
(:require [clojure.tools.nrepl.server]
[ultra.colorscheme :as colorscheme]
(:require [ultra.colorscheme :as colorscheme]
[robert.hooke :refer [add-hook]]))

;; For reasons that aren't totally clear to me, we need this import to find clojure.test?
(if (find-ns 'clojure.tools.nrepl)
(require
'[clojure.tools.nrepl.server :as nrepl-server])
(require
'[nrepl.server :as nrepl-server]))

(def configured? (atom {}))

(defmacro configure-repl!
Expand Down
26 changes: 21 additions & 5 deletions src/ultra/repl.clj
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
(ns ultra.repl
(:require [clojure.main :as main]
[clojure.repl :as repl]
[clojure.tools.nrepl.server]
[glow.terminal]
[glow.colorschemes]
[glow.parse]
[io.aviso.repl :as pretty-repl]
[puget.color.ansi :as ansi]
[ultra.printer :refer [cprint]]))

;; Compatibility with the legacy tools.nrepl and the new nREPL 0.4.x.
;; The assumption is that if someone is using old lein repl or boot repl
;; they'll end up using the tools.nrepl, otherwise the modern one.
(if (find-ns 'clojure.tools.nrepl)
(require
'[clojure.tools.nrepl.server :as nrepl-server])
(require
'[nrepl.server :as nrepl-server]))

(defmacro source
"Prints the source code for the given symbol, if it can find it.
This requires that the symbol resolve to a Var defined in a
Expand Down Expand Up @@ -84,10 +92,18 @@
"Alter the default handler to include the provided middleware."
{:added "0.1.0"}
[middleware]
(alter-var-root
#'clojure.tools.nrepl.server/default-handler
partial
middleware))
;; Compatibility with the legacy tools.nrepl and the new nREPL 0.4.x.
;; The assumption is that if someone is using old lein repl or boot repl
;; they'll end up using the tools.nrepl, otherwise the modern one.
(if (find-ns 'clojure.tools.nrepl)
(alter-var-root
#'clojure.tools.nrepl.server/default-handler
partial
middleware)
(alter-var-root
#'nrepl.server/default-handler
partial
middleware)))

(defn add-pretty-middleware
"Add Aviso's Pretty functionality"
Expand Down
1 change: 1 addition & 0 deletions src/ultra/repl/whidbey.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"Unfortunately, Whidbey has some import side-effects that require us to
dynamically import this namespace."
(:require [clojure.tools.nrepl.middleware.render-values :refer [render-values]]
;; note that the above dependency comes from Whidbey, not nREPL.
[ultra.repl :refer [add-middleware]]))

(defn add-whidbey-middleware
Expand Down

0 comments on commit cfd4cf4

Please sign in to comment.