Meikel  Brandmeyer avatar Meikel Brandmeyer committed 45624a2

Move to new task and subplugin

Comments (0)

Files changed (24)

+# clojuresque – a Clojure plugin for Gradle
+
+## What is Gradle?
+
+[Gradle][] is a build system written in Java and [Groovy][]. One advantage
+of [Gradle][] is, that the build script itself is also a [Groovy][] script.
+That means whatever can be done in [Groovy][] can be done in the build
+script. This is useful to abstract away common patterns in the build like
+repetition or conditional decisions.
+
+On top of that [Gradle][] provides a convenient build system which comes
+in form of different plugins. Each plugin defines certain conventions which
+(if followed) automasie 95% of the build completely. Still the conventions
+are freely configurable to be adapted to different project structures.
+
+## What is clojuresque?
+
+[clojuresque][cg] is now a plugin for [Gradle][], which adds [Clojure][clj]
+support. It allows compilation with automatic namespace recognition. The
+plugin is based on the Java plugin and hooks into the standard configurations
+and archives.
+
+## Usage
+
+Create a `build.gradle` script in the root directory of your project. *Note
+that gradle derives the project name from the name of this directory!*
+
+    buildscript {
+        repositories {
+            maven { url 'http://clojars.org/repo' }
+        }
+        dependencies {
+            classpath 'clojuresque:clojuresque-nrepl:1.0.0'
+        }
+    }
+    
+    apply plugin: 'clojure-nrepl'
+
+## NRepl
+
+The “nrepl” plugin adds a `clojureRepl` tasks, which starts up a
+nrepl process. This can be used by IDEs or similar empowered development
+environments and nrepl clients like reply.
+
+## Caveats
+
+ * Due to the way gradle handles the standard input there is no truely
+   interactive repl possible. However in the light of reply and similar
+   clients this is not really necessary.
+
+ * The started process blocks the terminal for now.
+
+## Issues
+
+This is **alpha** software! Expect problems! Please report issues in the
+bugtracker at [bitbucket][bb]. Or email them to me.
+
+General support is available on the [clojuresque google group][cgg].
+
+-- 
+Meikel Brandmeyer <mb@kotka.de>
+Frankfurt am Main, October 2013
+
+[Gradle]: http://www.gradle.org
+[Groovy]: http://groovy.codehaus.org
+[clj]:    http://clojure.org
+[cg]:     http://bitbucket.org/clojuresque/nrepl
+[bb]:     http://bitbucket.org/clojuresque/nrepl/issues
+[cgg]:    https://groups.google.com/forum/#!forum/clojuresque
 buildscript {
     repositories {
-        maven { url "http://127.0.0.1:8080/repository/internal" }
+        mavenCentral()
         maven { url "http://clojars.org/repo" }
     }
 
     dependencies {
-        classpath "de.kotka.gradle:gradle-plugin:1.0.1"
+        classpath "de.kotka.gradle:gradle-plugin:1.1.0"
     }
 }
 
-group   = "clojuresque"
-version = "1.1.0-SNAPSHOT"
+subprojects {
+    group = 'clojuresque'
+    version = '1.0.0-SNAPSHOT'
 
-ext."kotka.repository" = "clojuresque/nrepl"
+    ext.kotka = [
+        repository:     "clojuresque/nrepl",
+        wrapperVersion: "1.8"
+    ]
 
-apply plugin: "groovy"
-apply plugin: "kotka"
+    apply {
+        plugin 'java'
+        plugin 'kotka'
+    }
 
-dependencies {
-    compile localGroovy()
-    compile gradleApi()
-    runtime "clojuresque:clojuresque:1.5.4"
+    repositories {
+        mavenCentral()
+    }
+}
 
-    testCompile "org.spockframework:spock-core:0.7-groovy-1.8"
+project(':clojuresque-nrepl') {
+    description = "A Clojure plugin for gradle (nrepl)"
+
+    apply plugin: 'groovy'
+
+    dependencies {
+        compile gradleApi()
+        compile localGroovy()
+
+        compile "de.kotka.gradle:gradle-utils:0.1.1"
+        compile "clojuresque:clojuresque-base:1.6.0-SNAPSHOT"
+
+        testCompile('org.spockframework:spock-core:0.7-groovy-1.8') {
+            exclude group: 'org.codehaus.groovy', module: 'groovy-all'
+        }
+    }
+
+    compileGroovy {
+        sourceCompatibility = "1.6"
+        targetCompatibility = "1.6"
+    }
+
+    processResources {
+        inputs.property "version", {-> project.version}
+        from(sourceSets.main.resources.srcDirs) {
+            expand("version": project.version)
+        }
+    }
+}
+
+project(':clojuresque-nrepl-runtime') {
+    description = "A Clojure plugin for gradle (nrepl runtime files)"
+
+    apply plugin: "java"
+
+    dependencies {
+        compile "clojuresque:clojuresque-base-runtime:1.6.0-SNAPSHOT"
+    }
 }
 
 task wrapper(type: Wrapper) {
-    gradleVersion = "1.6"
+    gradleVersion = "1.8"
 }
Add a comment to this file

clojuresque-nrepl-runtime/gradle/wrapper/gradle-wrapper.jar

Binary file added.

clojuresque-nrepl-runtime/gradle/wrapper/gradle-wrapper.properties

+#Thu Oct 03 21:17:17 CEST 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip

clojuresque-nrepl-runtime/gradlew

+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

clojuresque-nrepl-runtime/gradlew.bat

+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

clojuresque-nrepl-runtime/src/main/resources/clojuresque/tasks/repl.clj

+(ns clojuresque.tasks.repl
+  (:require
+    [clojuresque.cli :as cli]
+    [clojuresque.util :as util]
+    [clojure.tools.nrepl.server :as repl]))
+
+(def barrier (promise))
+(def server nil)
+
+(cli/deftask start-repl
+  "Start a nrepl server on the given port. An optional handler
+  may be given as fully-qualified symbol. The repl server may
+  be stopped via clojuresque.tasks.repl/stop-server."
+  [[port     p "server port"]
+   [handler  h "handler function" nil]]
+  (let [p (Long/parseLong port)
+        h (if handler
+            (let [custom-handler (util/resolve-required handler)]
+              (when-not custom-handler
+                (throw (Exception. (str "Unknown handler: " handler))))
+              (custom-handler))
+            (repl/default-handler))
+        s (repl/start-server :port p :handler h)]
+    (println "Repl started on port" port)
+    (alter-var-root #'server (constantly s)))
+  @barrier)
+
+(defn stop-repl
+  []
+  (when server
+    (repl/stop-server server)
+    (deliver barrier true)))
Add a comment to this file

clojuresque-nrepl/gradle/wrapper/gradle-wrapper.jar

Binary file added.

clojuresque-nrepl/gradle/wrapper/gradle-wrapper.properties

+#Thu Oct 03 21:17:17 CEST 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip

clojuresque-nrepl/gradlew

+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

clojuresque-nrepl/gradlew.bat

+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

clojuresque-nrepl/src/main/groovy/clojuresque/ClojureReplPlugin.groovy

+/*-
+ * Copyright 2013 © Meikel Brandmeyer.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package clojuresque
+
+import clojuresque.tasks.ClojureReplTask
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+
+class ClojureReplPlugin implements Plugin<Project> {
+    void apply(Project project) {
+        project.apply plugin: "clojure-base"
+
+        def compileTaskName =
+            project.sourceSets.main.getCompileTaskName("clojure")
+        def compileTask = project.tasks[compileTaskName]
+
+        project.task("clojureRepl", type: ClojureReplTask) {
+            port = 7888
+            delayedJvmOptions = { compileTask.jvmOptions }
+            delayedClasspath  = {
+                def sourceRoots = project.sourceSets.collect {
+                    it.allSource.srcDirs
+                }
+
+                project.files(
+                    sourceRoots,
+                    project.configurations.testRuntime,
+                    project.configurations.development
+                )
+            }
+            description = "Run Clojure repl."
+            group = ClojureBasePlugin.CLOJURE_GROUP
+        }
+
+        def props = Util.properties("nrepl")
+
+        project.dependencies {
+            clojuresque group: "clojuresque",
+                name: "clojuresque-nrepl-runtime",
+                version: props.getProperty("clojuresque.nrepl.version")
+        }
+    }
+}

clojuresque-nrepl/src/main/groovy/clojuresque/tasks/ClojureReplTask.groovy

+/*-
+ * Copyright 2013 © Meikel Brandmeyer.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package clojuresque.tasks
+
+import kotka.gradle.utils.ConfigureUtil
+import kotka.gradle.utils.Delayed
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.tasks.InputFiles
+import org.gradle.api.tasks.TaskAction
+
+public class ClojureReplTask extends DefaultTask {
+    @InputFiles
+    @Delayed
+    def classpath
+
+    def classpath(Object... fs) {
+        classpath = this.getClasspath().plus(project.files(fs))
+    }
+
+    @Delayed
+    def jvmOptions
+
+    def port
+    def handler
+
+    @TaskAction
+    public void startRepl() {
+        def options = [ "--port", port ]
+        if (handler != null)
+            options += [ "--handler", handler ]
+
+        project.clojureexec {
+            ConfigureUtil.configure delegate, this.jvmOptions
+            classpath = this.classpath
+            main = "clojuresque.tasks.repl/start-repl"
+            args = options
+        }
+    }
+}

clojuresque-nrepl/src/main/resources/clojuresque/nrepl.properties

+clojuresque.nrepl.version = ${version}

gradle/wrapper/gradle-wrapper.properties

-#Mon May 20 22:55:21 CEST 2013
+#Thu Oct 03 21:17:16 CEST 2013
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
-rootProject.name = "nrepl"
+rootProject.name = "root-nrepl"
+include "clojuresque-nrepl"
+include "clojuresque-nrepl-runtime"

src/main/groovy/clojuresque/nrepl/NReplPlugin.groovy

-/*-
- * Copyright 2013 © Meikel Brandmeyer.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package clojuresque.nrepl
-
-import clojuresque.nrepl.tasks.StartTask
-import clojuresque.nrepl.tasks.StopTask
-
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-
-public class NReplPlugin implements Plugin<Project> {
-    final static String taskGroup = "Clojure NRepl server tasks"
-
-    void apply(Project project) {
-        project.apply plugin: "clojure"
-
-        project.task("startNRepl", type: StartTask) {
-            replInfo = "nreplPort.txt"
-            replClasspath = project.files(
-                project.sourceSets.main.clojure.srcDirs,
-                project.sourceSets.main.resources.srcDirs,
-                project.sourceSets.test.clojure.srcDirs,
-                project.sourceSets.test.resources.srcDirs,
-                project.configurations.testRuntime,
-                project.configurations.development
-            )
-            group = taskGroup
-            description = "Start a nrepl server in the background"
-        }
-
-        project.task("stopNRepl", type: StopTask) {
-            from project.startNRepl
-            group = taskGroup
-            description = "Stop a running background nrepl server"
-        }
-    }
-}

src/main/groovy/clojuresque/nrepl/Utils.groovy

-/*-
- * Copyright 2013 © Meikel Brandmeyer.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package clojuresque.nrepl
-
-import groovy.lang.Closure
-
-class Utils {
-    static lazyValue(thing, nullValue=null) {
-        if (thing == null)
-            return nullValue
-
-        if (thing instanceof Closure)
-            return thing()
-
-        return thing
-    }
-}

src/main/groovy/clojuresque/nrepl/tasks/StartTask.groovy

-/*-
- * Copyright 2013 © Meikel Brandmeyer.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package clojuresque.nrepl.tasks
-
-import clojuresque.nrepl.Utils
-
-import org.gradle.api.DefaultTask
-import org.gradle.api.tasks.TaskAction
-
-public class StartTask extends DefaultTask {
-    def replInfo
-    def replClasspath
-    def replPort
-    def init = []
-
-    def getReplInfo() {
-        def info = Utils.lazyValue(this.replInfo)
-        info ? project.file(info) : null
-    }
-
-    def getReplClasspath() {
-        def path = Utils.lazyValue(this.replClasspath)
-        path ? project.files(path) : null
-    }
-
-    def getReplPort() {
-        Utils.lazyValue(this.replPort, 0)
-    }
-
-    @TaskAction
-    void startNRepl() {
-        ant.java(
-            classname: "clojure.main",
-            spawn:     true,
-            fork:      true
-        ) {
-            classpath path: getReplClasspath().asPath
-            arg value: "-e"
-            arg value: this.commandString()
-        }
-    }
-
-    String commandString() {
-        def info = getReplInfo()
-        def port = getReplPort()
-
-        String.format('''
-                (do
-                  %s
-                  (ns clojuresque.nrepl-server)
-                  (require 'clojure.tools.nrepl.server)
-                  (def server
-                    (clojure.tools.nrepl.server/start-server :port %d))
-                  (defn shutdown
-                    []
-                    (.close server)
-                    (shutdown-agents))
-                  %s)
-                ''',
-                init.join(" "),
-                port,
-                info ?
-                    String.format('''
-                        (with-open [writer (java.io.FileWriter. "%s")]
-                          (binding [*out* writer]
-                            (prn (:port server))
-                            (flush)))
-                        ''',
-                        info.
-                            path.
-                            replaceAll("\\\\", "\\\\").
-                            replaceAll("\"", "\\\"")) :
-                    "")
-    }
-}

src/main/groovy/clojuresque/nrepl/tasks/StopTask.groovy

-/*-
- * Copyright 2013 © Meikel Brandmeyer.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package clojuresque.nrepl.tasks
-
-import clojuresque.nrepl.Utils
-
-import org.gradle.api.DefaultTask
-import org.gradle.api.InvalidUserDataException
-import org.gradle.api.tasks.TaskAction
-
-public class StopTask extends DefaultTask {
-    final static byte[] command =
-        "d4:code35:(clojuresque.nrepl-server/shutdown)2:op4:evale".bytes
-
-    def replInfo
-    def replPort
-
-    def getReplInfo() {
-        def info = Utils.lazyValue(this.replInfo)
-        info ? project.file(info) : null
-    }
-
-    def getReplPort() {
-        Utils.lazyValue(this.replPort, 0)
-    }
-
-    void from(startTask) {
-        replInfo = { -> startTask.replInfo }
-        replPort = { -> startTask.replPort }
-    }
-
-    @TaskAction
-    void stopNRepl() {
-        int  port = getReplPort()
-        File info = getReplInfo()
-
-        if (info != null && info.exists()) {
-            port = Integer.parseInt(info.readLines().get(0))
-            info.delete()
-        }
-
-        if (port > 0) {
-            Socket s = new Socket("127.0.0.1", port)
-            s.withStreams { input, output ->
-                output.write(command)
-                output.flush()
-            }
-        } else
-            throw new InvalidUserDataException("Neither replInfo file nor port given. Cannot stop process!")
-    }
-}

src/main/resources/META-INF/gradle-plugins/nrepl.properties

-implementation-class=clojuresque.nrepl.NReplPlugin

src/test/groovy/clojuresque/nrepl/TestNReplPlugin.groovy

-/*-
- * Copyright 2013 © Meikel Brandmeyer.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package clojuresque.nrepl
-
-import clojuresque.nrepl.tasks.StartTask
-import clojuresque.nrepl.tasks.StopTask
-
-import org.gradle.testfixtures.ProjectBuilder
-
-import spock.lang.Specification
-
-public class TestNReplPlugin extends Specification {
-    def pluginSetsupTasks() {
-        setup:
-        def p = ProjectBuilder.builder().build()
-
-        when:
-        p.apply plugin: "nrepl"
-
-        then:
-        p.startNRepl instanceof StartTask
-        p.stopNRepl  instanceof StopTask
-        p.startNRepl.replInfo == p.stopNRepl.replInfo
-    }
-}

src/test/groovy/clojuresque/nrepl/tasks/TestNReplTasks.groovy

-/*-
- * Copyright 2013 © Meikel Brandmeyer.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package clojuresque.nrepl.tasks
-
-import org.gradle.api.GradleException
-import org.gradle.api.InvalidUserDataException
-import org.gradle.api.logging.LogLevel
-import org.gradle.testfixtures.ProjectBuilder
-
-import spock.lang.Specification
-
-public class TestNReplTasks extends Specification {
-    def "tasks communicate via info file"() {
-        setup: "the temporary replInfo file"
-        def i = File.createTempFile("replInfo.", ".edn")
-
-        and: "the temporary project used to run the tasks"
-        def p = buildProject()
-
-        when: "the start task is configured properly"
-        def t = p.task("startNRepl", type: StartTask)
-        t.replInfo = i
-        t.replClasspath = p.files(p.configurations.nrepl)
-
-        and: "the stop task is configured properly"
-        def s = p.task("stopNRepl", type: StopTask)
-        s.from t
-
-        and: "the start task is executed"
-        t.execute()
-        Thread.sleep(5000) // XXX: Wait for server spin-up.
-
-        then: "the repl port is written to the replInfo file"
-        i.length() > 0
-
-        when: "the port is read"
-        def port = findReplInfo(i)
-
-        and: "the connection is tried"
-        testConnection(port)
-
-        then: "it succeeds"
-        notThrown(ConnectException)
-
-        when: "the stop task is executed"
-        s.execute()
-        Thread.sleep(5000) // XXX: Wait for server spin-down.
-
-        then: "the repl info file is removed"
-        !i.exists()
-
-        when: "the connection is tried again"
-        testConnection(port)
-
-        then: "it fails"
-        thrown(ConnectException)
-
-        cleanup:
-        if (i.exists())
-            i.delete()
-    }
-
-    def "tasks communicate via explicit port configuration"() {
-        setup: "the temporary project used to run the tasks"
-        def p = buildProject()
-
-        when: "the start task is configured properly"
-        def t = p.task("startNRepl", type: StartTask)
-        t.replPort = 4711
-        t.replClasspath = p.files(p.configurations.nrepl)
-
-        and: "the stop task is configured properly"
-        def s = p.task("stopNRepl", type: StopTask)
-        s.from t
-
-        and: "the start task is executed"
-        t.execute()
-        Thread.sleep(5000) // XXX: Wait for server spin-up.
-
-        and: "the connection is tried"
-        testConnection(4711)
-
-        then: "it succeeds"
-        notThrown(ConnectException)
-
-        when: "the stop task is executed"
-        s.execute()
-        Thread.sleep(5000) // XXX: Wait for server spin-down.
-
-        and: "the connection is tried again"
-        testConnection(4711)
-
-        then: "it fails"
-        thrown(ConnectException)
-    }
-
-    def "starting the server respects initialisation"() {
-        setup: "the temporary project used to run the tasks"
-        def p = buildProject()
-
-        when: "the start task is configured properly"
-        def t = p.task("startNRepl", type: StartTask)
-        t.replPort = 4711
-        t.replClasspath = p.files(p.configurations.nrepl)
-        t.init << "(throw (Exception. \"Kill starting process!\"))"
-
-        and: "it is executed"
-        t.execute()
-        Thread.sleep(5000) // XXX: Wait for server spin-up.
-
-        and: "a connection is tried"
-        testConnection(4711)
-
-        then: "it fails"
-        thrown(ConnectException)
-    }
-
-    def "stop task requires either info file or explicit port"() {
-        setup: "the temporary project used to run the tasks"
-        def p = buildProject()
-
-        when: "the stop task is not properly configured"
-        def s = p.task("stopNRepl", type: StopTask)
-
-        and: "it is executed"
-        s.execute()
-
-        then: "an InvalidUserDataException is thrown"
-        def e = thrown(GradleException)
-        rootCause(e) instanceof InvalidUserDataException
-    }
-
-    def "stop task is configured lazily"() {
-        setup: "the temporary project used to run the tasks"
-        def p = buildProject()
-        def r = new Random()
-
-        and: "some random options are generated"
-        def input = File.createTempFile("replInfo.", ".edn")
-        def port  = r.nextInt(65536)
-
-        when: "the tasks are added"
-        def start = p.task("startNRepl", type: StartTask)
-        def stop  = p.task("stopNRepl",  type: StopTask)
-
-        and: "the stop task is configured from the start task"
-        stop.from start
-
-        and: "the start task is configured afterwards"
-        start.replInfo = input
-        start.replPort = port
-
-        then: "the stop inherits the configured options"
-        stop.replInfo == start.replInfo
-        stop.replPort == start.replPort
-
-        cleanup:
-        input.delete()
-    }
-
-    /* Helper functions: */
-    static buildProject() {
-        def p = ProjectBuilder.builder().build()
-        // TODO: Doesn't work. Gradle issue?
-        p.logging.level = LogLevel.INFO
-        p.apply from:
-            Thread.
-                currentThread().
-                    contextClassLoader.
-                        getResource("clojuresque/nrepl/nrepl_test_params.gradle")
-        return p
-    }
-
-    static rootCause(exc) {
-        while (exc.cause != null)
-            exc = exc.cause
-        return exc
-    }
-
-    static findReplInfo(file) {
-        Integer.parseInt(file.readLines().first())
-    }
-
-    static testConnection(port) {
-        def s = new Socket("127.0.0.1", port)
-        s.close()
-    }
-}

src/test/resources/clojuresque/nrepl/nrepl_test_params.gradle

-repositories {
-    maven { url "http://127.0.0.1:8080/repository/internal" }
-    mavenCentral()
-}
-
-configurations { nrepl }
-
-dependencies {
-    nrepl "org.clojure:clojure:1.5.1"
-    nrepl "org.clojure:tools.nrepl:0.2.2"
-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.