The only downside is that it's early in intp init. I remember from the time of my previous post:
http://stackoverflow.com/a/23646271/1296806where the issue was that "$intp" isn't available yet from sbt. I see the context classloader isn't set yet.
I once rejiggered the startup and provided a nicer hook, but currently, I see a sample from last January:
import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.ILoop
object Test extends App {
val foo = 42
val code = """
import concurrent._, ExecutionContext.Implicits._
$intp.getContext.getScopes
val f = Future(8)
foo
f
""".lines.toList
val repl = new ILoop {
override def printWelcome() = {
processLine("")
intp.bind("foo", foo)
code foreach intp.interpret
super.printWelcome()
echo("Customized...")
}
}
val s = new Settings
s.usejavacp.value = true
s.Xnojline.value = true
repl process s
}
The call to `processLine` tries to make sure the compiler is initialized.