Alexander Chepurnoy
Alexander Chepurnoy

Reputation: 615

Run start script generation from SBT task

I have this in my build.sbt :

Seq(SbtStartScript.startScriptForClassesSettings:_*)

and then I can generate start script with sbt start-script. How can I generate start script in a task, e.g. how to add start script generation after cleaning/compiling to this:

val recompile = taskKey[Unit]("Recompile")
recompile := {
  clean.value
  compile.value
}

Upvotes: 1

Views: 232

Answers (1)

Martin Senne
Martin Senne

Reputation: 6059

According to the source at GitHub for sbt-start-script, line 35, sbt-start-script is just a regular task.

So, what prevents you from doing :

val recompile = taskKey[Unit]("Recompile")
recompile := {
  clean.value
  compile.value
  startScriptForClasses.value
}

Take care, that all these tasks are run in parallel. (see http://www.scala-sbt.org/0.13/docs/sbt-0.13-Tech-Previews.html#Sequential+tasks for details)

E.g. if you use SBT >= 0.13.8. you can use

recompile := Def.sequential(clean in Compile, compile in Compile, startScriptForClasses).value

Otherwise, if SBT <= 0.13.7, use the sbt-sequential plugin ( https://github.com/sbt/sbt-sequential )

Alternative

Also see Run custom task automatically before/after standard task

Upvotes: 1

Related Questions