Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT console - How to run stuff on initialization?

Tags:

scala

sbt

lift

I am using sbt console to debug some web application, written with Lift Framework.

Every time running it, I run some commands to initialize framework.

import bootstrap.liftweb.Boot
(new Boot).boot
import ...some frequently used models from my app...

I want sbt to do this boilerplate every time I start it.

How to do this?

like image 621
uhbif19 Avatar asked Mar 02 '14 22:03

uhbif19


People also ask

What does sbt reload do?

object Reload extends CancelWatch with Product with Serializable. Action that indicates that the watch should pause while the build is reloaded. This is used to automatically reload the project when the build files (e.g. build. sbt) are changed.

How do I compile a Scala project?

Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Build Tools | sbt. In the sbt projects section, select a project for which you want to configure build actions. In the sbt shell section, select the builds option. Click OK to save the changes.


1 Answers

The simple way to do that, is put "initialCommands" rule in build.sbt.

This example:

initialCommands in console := """println("Hello from console")"""

will print in console, after initialization

Hello from console

Provided by https://stackoverflow.com/a/12703977/225767

like image 188
uhbif19 Avatar answered Oct 03 '22 21:10

uhbif19