Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add experimental support for :eval-in :nrepl.

  • Loading branch information...
commit f822cedeac2cf7d442c6abd97bb4f5cc5be8c766 1 parent 6dbdada
@technomancy authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 leiningen-core/src/leiningen/core/eval.clj
20 leiningen-core/src/leiningen/core/eval.clj
@@ -262,6 +262,26 @@
(.printStackTrace e)
(throw (ex-info "Classloader eval failed" {:exit-code 1}))))))
+(defmethod eval-in :nrepl [project form]
+ (require '
+ (let [port-file (io/file (:target-path project) "repl-port")
+ connect (resolve '
+ client (resolve '
+ client-session (resolve '
+ message (resolve '
+ recv (resolve ']
+ (if (.exists port-file)
+ (let [transport (connect :host "localhost"
+ :port (Integer. (slurp port-file)))
+ client (client-session (client transport Long/MAX_VALUE))]
+ (message client {:op "eval" :code (pr-str form)})
+ (doseq [{:keys [out err status]} (repeatedly #(recv transport 100))
+ :while (not (some #{"done" "interrupted" "error"} status))]
+ (when out (println out))
+ (when err (binding [*out* *err*] (println err)))))
+ ;; TODO: warn that repl couldn't be used?
+ (eval-in (assoc project :eval-in :subprocess) form))))
(defmethod eval-in :leiningen [project form]
(when (:debug project)
(System/setProperty "clojure.debug" "true"))
Please sign in to comment.
Something went wrong with that request. Please try again.