Reputation: 1041
I use scala sbt console to test my methods. (commands : sbt then console) But the code changes done in eclipse or other external editor, are not getting reflected in the sbt console.
Every time, I have to quit the console (using Crt + D) and again start it using console command to see the changes.
Any one facing this problem? Is there any ways to reload the code from console?
I am using Ubuntu 64-Bit,
Upvotes: 42
Views: 13363
Reputation: 2832
Not without using something like JRebel, mostly because class definitions could break in such a way as to make instances already loaded unusable. The only suggestion I have is to run the console with ~console so that if changes have been made they will be recompiled and the console re-entered.
Also if you're regularly running a set of commands the initialCommands sbt setting configures commands to be run immediately after starting the console.
Upvotes: 35
Reputation: 56595
One option is to use :restart
in the console - this will reload it and replay all the commands you've entered so far.
For a better solution you might want to read my blog post on incremental development with JRebel & Scala.
You should modify the sbt startup script like this:
#!/bin/bash
java -noverify -javaagent:/home/username/path/to/jrebel/jrebel/jrebel.jar
-Drebel.lift_plugin=true -XX:+CMSClassUnloadingEnabled
-XX:MaxPermSize=512m -Xmx512M -Xss2M -jar `dirname $0`/sbt-launch.jar
"$@"
When you start the REPL from inside SBT, for instance with the command:
sbt console
changes to the imported classes will be reflected automatically without the need to do a :replay
or restart
the REPL - something reminiscent of the interactive Lisp programming.
Upvotes: 20