问题
If we define initialCommands in console += "1+1"
this will run after console is executed.
Is it possible to run a command after sbt starts, like initialCommands in sbtStartup += "console"
to enter the console automatically?
I'd like to keep the session (after executing the command) active.
回答1:
from http://www.scala-sbt.org/0.13.5/docs/faq.html#how-can-i-take-action-when-the-project-is-loaded-or-unloaded
http://www.scala-sbt.org/0.13.5/api/index.html#sbt.StateOps
onLoad in Global := {
((s: State) => { "console" :: s }) compose (onLoad in Global).value
}
回答2:
Executing sbt launcher with a task or command on command line executes it after sbt is up and running. sbt console
would give you what you're after yet sbt will shutdown after the task/command finishes (I can only suspect that was the intent of the OP).
来源:https://stackoverflow.com/questions/25388592/how-to-run-a-command-when-sbt-starts-and-keep-the-session-active