Minimum build.gradle :
apply plugin: 'scala' repositories{ mavenCentral() } dependencies{ compile "org.scala-lang:scala-library:2.11.7" compile "org.scala-lang:scala-compiler:2.11.7" } task repl(type:JavaExec) { main = "scala.tools.nsc.MainGenericRunner" classpath = sourceSets.main.runtimeClasspath standardInput System.in args '-usejavacp' }
Confirm this answer to explain how to direct stdin with standard input and use REPL the correct path to the args path.
Note that the scala-compiler library is a dependency. This is where scala.tools.nsc.MainGenericRunner found.
On the console, to run REPL, you need several parameters:
--no-daemon if you are using the Gradle daemon. Currently REPL does not respond to keystrokes if they are launched from the daemon.
--console plain . A popular but lower alternative is --quiet . If run without one of these options, the REPL query is dirty with the Gradle Progress Report. The advantage of --console plain is that it also adjusts the readline behavior, so rlwrap not required.
The full command to run REPL is gradle repl --console plain --no-daemon , so creating an alias in your shell makes sense.
Dominykas mostauskis
source share