Ruby has IRB (interactive ruby shell). Scala has REPL.
When developing a Rails application, I frequently use the Rails Console to debug Rails project code. Execute the following command from the OS shell, e.g., Bash, in your Rails project:
rails c
The default environment is development, but you can also open the rails console for test or production (or any custom environment you create)
Rake is the Ruby-based build tool for Rails apps.
Similarly, SBT is the scala-based build tool used for Play applications.
SBT is typically used to compile and execute a Scala scripts containing dependency declarations or other sbt settings.
I created a script to start SBT for my project that looks like:
sbt.sh
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2048M -noverify -jar -Dcom.company.project.common.util.devmode=yes $HOME/opt/sbt/bin/sbt-launch.jar "$@"
That allows me to run commands like:
update
gen-idea
project project_name
clean
compile
But I wanted to actually run scala commands and exercise application APIs.
I'd get errors like the following:
SBT Console
$ sbt-no-repl.sh
Listening for transport dt_socket at address: 8000
[info] Loading project definition from /hs/dev/company/project
[info] Set current project to ap (in build file:/hs/dev/company/)
project:master:5.0-SNAPSHOT>
project:master:5.0-SNAPSHOT> var allProducts = new ListBuffer[String]()
[error] Not a valid key: var (similar: start, run, target)
[error] var allProducts = new ListBuffer[String]()
[error] ^
project:master:5.0-SNAPSHOT> import collection.mutable.ListBuffer
[error] Not a valid key: import (similar: port)
[error] import collection.mutable.ListBuffer
[error] ^
... until I learned how to startup the Scala REPL, defining the dependencies that should be on the classpath, and adding that to my SBT script:
sbt.sh
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2048M -noverify -jar -Dnet.tstllc.common.util.devmode=yes -Dsbt.main.class=sbt.ConsoleMain -Dsbt.boot.directory=/Volumes/HoneyBadger1TB/Users/lex/.sbt/boot $HOME/opt/sbt/bin/sbt-launch.jar "$@"
SBT (with REPL) Console
$ sbt
Listening for transport dt_socket at address: 8000
[info] Set current project to default-3bc954 (in build file:/Volumes/HoneyBadger1TB/Users/lex/.sbt/boot/ivy-console/)
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.
scala> var allProducts = new ListBuffer[String]()
<console>:7: error: not found: type ListBuffer
var allProducts = new ListBuffer[String]()
^
scala> import collection.mutable.ListBuffer
import collection.mutable.ListBuffer
scala> var allProducts = new ListBuffer[String]()
allProducts: scala.collection.mutable.ListBuffer[String] = ListBuffer()
scala> allProducts += "1"
res0: scala.collection.mutable.ListBuffer[String] = ListBuffer(1)
scala> allProducts += "2"
res1: scala.collection.mutable.ListBuffer[String] = ListBuffer(1, 2)
scala>
References
http://www.scala-sbt.org/
http://www.scala-sbt.org/release/docs/Detailed-Topics/Scripts.html
http://www.playframework.org/
http://www.playframework.org/
http://rake.rubyforge.org/
Special thanks to Kyle Unverferth!
Just found out that the above really only applies to non-play sbt projects.
ReplyDeleteFor play apps, similar to Rails apps, you can just type "console" at the sbt prompt :-)
The strategy you have posted on this technology helped me to get into the next level and had lot of information in it. Python Training in Chennai
ReplyDeleteInspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..
ReplyDeleteClick here:
angularjs training in sholinganallur
Click here:
angularjs training in btm
Click here:
angularjs training in rajajinagar
Have you been thinking about the power sources and the tiles whom use blocks I wanted to thank you for this great read!! I definitely enjoyed every little bit of it and I have you bookmarked to check out the new stuff you post
ReplyDeleteClick here:
Microsoft azure training in annanagar
Click here:
Microsoft azure training in velarchery
Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
ReplyDeleteBlueprism training in Chennai
Blueprism training in Bangalore
Blueprism training in Pune
Blueprism online training
Blueprism training in tambaram
The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.Devops training in sholinganallur
ReplyDeleteAwesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
ReplyDeleteData Science Training in Chennai | Data Science course in anna nagar
Data Science course in chennai | Data science course in Bangalore
Data Science course in marathahalli | Data Science course in btm
I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog.
ReplyDeletejava training in chennai | java training in bangalore
java interview questions and answers | core java interview questions and answers
And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most effective I’ve had.• And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most safety course in chennai
ReplyDeleteeffective I’ve had.
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Python online training
uipath online training
And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most effective I’ve had.
ReplyDeleteData science Course Training in Chennai | No.1 Data Science Training in Chennai
RPA Course Training in Chennai | No.1 RPA Training in Chennai
very nice post...
ReplyDeleteinplant training in chennai
inplant training in chennai
inplant training in chennai for it
Australia hosting
mexico web hosting
moldova web hosting
albania web hosting
andorra hosting
australia web hosting
denmark web hosting
very nice....
ReplyDeleteinplant training in chennai
inplant training in chennai for it
Bermuda web hosting
Botswana hosting
armenia web hosting
dominican republic web hosting
iran hosting
palestinian territory web hosting
iceland web hosting
good
ReplyDeleteBermuda web hosting
Botswana hosting
armenia web hosting
lithuania shared web hosting
inplant training in chennai
inplant training in chennai for it
suden web hosting
tunisia hosting
uruguay web hosting
nice post...!
ReplyDeleteinternship in chennai for ece students
internships in chennai for cse students 2019
Inplant training in chennai
internship for eee students
free internship in chennai
eee internship in chennai
internship for ece students in chennai
inplant training in bangalore for cse
inplant training in bangalore
ccna training in chennai
One of the great article, I have seen yet. Waiting for more updates.keep on update guys.
ReplyDeleteAi & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
This comment has been removed by the author.
ReplyDeleteslot siteleri
ReplyDeletekralbet
betpark
tipobet
betmatik
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
GRSİGİ
شركة مكافحة النمل الابيض بالاحساء g1wvXFgGBp
ReplyDelete