Reputation: 1099
When scala REPL starts some default packages like scala.lang._ , scala.Predef are automatically available.Suppose I have my own package like com.raghhuraamm.rUtils._
How to import this package automatically when REPL starts? Is there a way or I just have to type "import com.raghhuraamm.rUtils._ " every time I start scala REPL?
Upvotes: 1
Views: 227
Reputation: 4145
If you could use sbt console
to launch the REPL, you can create a build.sbt
containing this line:
initialCommands in Compile in console += "import com.raghhuraamm.rUtils._"
Source: https://www.scala-sbt.org/1.x/docs/Inspecting-Settings.html
Upvotes: 1
Reputation: 44967
Create a script (myPreload.scala
, say) that contains all the imports that you want:
// in myPreload.scala
import com.raghhuraamm.rUtils._
Assuming that the classes are packaged in my.jar
, start the scala
repl as follows:
scala -cp path/to/my.jar -i some/other/path/to/myPreload.scala
Upvotes: 0