//
// Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
//
name := """netty-channel-options"""
organization := "com.lightbend.play"

version := "1.0-SNAPSHOT"

lazy val root = (project in file("."))
  .enablePlugins(PlayScala)
  .enablePlugins(PlayNettyServer)
  .disablePlugins(PlayAkkaHttpServer)
  .settings(
    scalaVersion := sys.props("scala.version"),
    updateOptions := updateOptions.value.withLatestSnapshots(false),
    evictionWarningOptions in update ~= (_.withWarnTransitiveEvictions(false).withWarnDirectEvictions(false)),
    PlayKeys.playInteractionMode := play.sbt.StaticPlayNonBlockingInteractionMode,
    libraryDependencies += guice,
    InputKey[Unit]("callIndex") := {
      try ScriptedTools.callIndex() catch { case e: java.net.ConnectException =>
        play.sbt.run.PlayRun.stop(state.value)
        throw e
      }
    },
    InputKey[Unit]("checkLines") := {
      val args                  = Def.spaceDelimited("<source> <target>").parsed
      val source :: target :: _ = args
        try ScriptedTools.checkLines(source, target) catch { case e: java.net.ConnectException =>
          play.sbt.run.PlayRun.stop(state.value)
          throw e
        }
    }
  )

//
// Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
//
name := """netty-channel-options"""
organization := "com.lightbend.play"

version := "1.0-SNAPSHOT"

lazy val root = (project in file("."))
  .enablePlugins(PlayScala)
  .enablePlugins(PlayNettyServer)
  .disablePlugins(PlayAkkaHttpServer)
  .settings(
    scalaVersion := sys.props("scala.version"),
    updateOptions := updateOptions.value.withLatestSnapshots(false),
    evictionWarningOptions in update ~= (_.withWarnTransitiveEvictions(false).withWarnDirectEvictions(false)),
    PlayKeys.playInteractionMode := play.sbt.StaticPlayNonBlockingInteractionMode,
    libraryDependencies += guice,
    InputKey[Unit]("callIndex") := ScriptedTools.callIndex(),
    InputKey[Unit]("checkLines") := {
      val args                  = Def.spaceDelimited("<source> <target>").parsed
      val source :: target :: _ = args
      ScriptedTools.checkLines(source, target)
    }
  )

--- 
+++ 
@@ -16,10 +16,18 @@
     evictionWarningOptions in update ~= (_.withWarnTransitiveEvictions(false).withWarnDirectEvictions(false)),
     PlayKeys.playInteractionMode := play.sbt.StaticPlayNonBlockingInteractionMode,
     libraryDependencies += guice,
-    InputKey[Unit]("callIndex") := ScriptedTools.callIndex(),
+    InputKey[Unit]("callIndex") := {
+      try ScriptedTools.callIndex() catch { case e: java.net.ConnectException =>
+        play.sbt.run.PlayRun.stop(state.value)
+        throw e
+      }
+    },
     InputKey[Unit]("checkLines") := {
       val args                  = Def.spaceDelimited("<source> <target>").parsed
       val source :: target :: _ = args
-      ScriptedTools.checkLines(source, target)
+        try ScriptedTools.checkLines(source, target) catch { case e: java.net.ConnectException =>
+          play.sbt.run.PlayRun.stop(state.value)
+          throw e
+        }
     }
   )
Make callIndex/checkLines stop the server
