Embedding scala 2.13.x REPL

230 Views Asked by At

For Scala 2.12.x one could use scala.tools.nsc.interpreter.ILoop to embed the Scala REPL. With Scala 2.13.x scala.tools.nsc.interpreter.ILoop has been removed. How could one embed the Scala 2.13.x REPL?

1

There are 1 best solutions below

0
Mario Galic On BEST ANSWER

Try adding scala-compiler dependency

libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.13.1"

after which, for example, the following compiles

import scala.tools.nsc.interpreter.shell.{ILoop, ShellConfig}
import scala.tools.nsc._

object EmbeddedREPL extend App {
  val settings = new Settings {
    usejavacp.value = true
    deprecation.value = true
  }
  val config = ShellConfig(settings)
  new ILoop(config).run(settings)
}