I want to define an sbt task that would start the scala console with project's compiled classes on the classpath and some initial commands executed.
I want to start that REPL session like this
sbt session
Here is my sorry attempt that I put together based on other answers, but it neither puts the project's classes on the classpath, nor doesn't execute the initial commands:
// extend Test in hope to include compiled sources on the classpath.
val ReplSession = config("repl-session") extend(Test)
val root = project.in(file("."))
.configs(ReplSession)
.settings(inConfig(ReplSession)(initialCommands := """
| import foo._
| """.stripMargin))
// define task that starts the REPL session
lazy val session = TaskKey[Unit]("session")
session <<= Seq(
console in (root, ReplSession)
).dependOn