Launch REPL for project

Issue #10 resolved
Howard Lewis Ship
created an issue

It would be nice if there was a very easy way to launch a REPL for the project.

Comments (11)

  1. Meikel Brandmeyer

    Unfortunately this is not possible due to the way gradle handles stdin and stdout.

    However I plan to have a task to start a nrepl server. Then another client of your choice can be used to contact the started repl.

  2. Howard Lewis Ship reporter

    I've pursued the nREPL approach and it seems to be working quite well! I'm living the dream ... stay in emacs for most everything.

    ... then I have to go back to Java coding :-(

  3. Peter Niederwieser

    Just to let you know, we are aware that Gradle's stdin/stdout handling needs to be improved, and it is on our list. (Gradle's Scala and Groovy plugins suffer from the same problem - no (good) REPL support.) However, I can't say when it will happen.

  4. Howard Lewis Ship reporter

    Here's a few snippets from our build script that may apply.

          configurations {
            nrepl.extendsFrom testRuntime
         dependencies {
            // Adds some useful extras when running nrepl
            nrepl "org.clojure:java.classpath:0.2.0"
            nrepl "org.clojure:tools.namespace:0.2.3"
            nrepl "clojure-complete:clojure-complete:0.2.3"
          task nrepl(type: JavaExec) {
            group "Other"
            description "Launches nREPL so that other tools (Emacs) can connect"
            maxHeapSize "1024M"
            // This prevents an unwanted Dock icon on Mac OS X
            // But prevents browser opening on Linux! 
            if ([''].toLowerCase().contains('mac os')) {
                systemProperty "java.awt.headless", "true"
            classpath configurations.provided
            classpath configurations.nrepl
            classpath sourceSets.main.clojure.srcDirs
            classpath sourceSets.test.clojure.srcDirs
            classpath "src/main/resources"
            classpath "src/test/resources"
            main "novate.nrepl"
    (ns novate.nrepl
       [ :only [start-server stop-server]])
    (defn -main [& args]
      (println "Starting nREPL server on port 7888")
      (start-server :port 7888)
      (doseq [n args]
        (println "Requiring namespace" n)
        (require (symbol n))))
  5. Meikel Brandmeyer

    Thank you for the input. I already worked on the task and a first stab is available in the current 1.6.0-SNAPSHOT. Your example would boil down to the following in your build.gradle.

    dependencies {
        development "org.clojure:tools.nrepl:0.2.3"
        development "org.clojure:java.classpath:0.2.0"
        development "org.clojure:tools.namespace:0.2.3"
        development "clojure-complete:clojure-complete:0.2.3"
    clojureRepl {
        jvmOptions = {
            maxHeapSize "1024M"
            if ([''].toLowerCase().contains('mac os')) {
                systemProperty "java.awt.headless", "true"
        classpath project.configurations.provided

    The actual repl is accessible through a suitable client (IDE, reply, ...).

    The point about the headless property is interesting. I think I will include this.

  6. Log in to comment