You can start a console with a classpath set with the project dependencies (compile, test, runtime) and compiler classes (main and test):
mvn test-compile #or mvn test
mvn scala:console
...
[INFO] [scala:console]
Welcome to Scala version 2.6.0-final.
Type in expressions to have them evaluated.
Type :help for more information.
scala> print("hello")
hello
scala> new bootstrap.liftweb.Boot().boot
...
If you want to always run some code before use the console or after use it, and don't want to type it at every startup. Then you could wrap the console into a scala main().
I'll show an example with the LiftConsole. A good pratice is to put this class in the test directory (it's not part of the main code ;) )
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<scope>test</scope>
</dependency>
import bootstrap.liftweb.Boot
import scala.tools.nsc.MainGenericRunner
object LiftConsole {
def main(args : Array[String]) {
// Instantiate your project's Boot file
val b = new Boot();
// Boot your project
b.boot;
// Now run the MainGenericRunner to get your repl
MainGenericRunner.main(args)
// After the repl exits, then exit the scala script
exit(0)
}
}
mvn test
mvn scala:console -DmainConsole=LiftConsole
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
...
<configuration>
<mainConsole>LiftConsole</mainConsole>
</configuration>
</plugin>
If you want to run the console with JavaRebel, you need :
mvn scala:console -Djavarebel.jar.path=[path_of_javarebel.jar]
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
...
<configuration>
<javaRebelPath>${user.home}/lib/java/javarebel/javarebel.jar</javaRebelPath>
</configuration>
</plugin>
MAVEN_OPTS="$MAVEN_OPTS -noverify -javaagent:/...path/to/jrebel.jar" mvn scala:console