Reputation: 11
I have just started using sbt
and am not too sure exactly how it works, I have created a task in the build.sbt
file
lazy val execScript = taskKey[Unit]("Execute the shell script")
execScript := {
"C:/Users/dsweeney/Documents/configuration-services/swagger/codegen/SwaggerActivate.bat" !
}
I can run it fine but I want it to run every time the build file is run, how exactly do I do this?
I have been trying to add it to the .aggerate
method
lazy val root = Project(
id = "configsvcs",
base = file(".")
).dependsOn(data_model)
.aggregate(data_model, slickMigration, execScript )
but that doesn't appear to be working error is Too many arguments for method aggregate.
thanks
Upvotes: 0
Views: 818
Reputation: 4608
It seems you want to generate source files during your build. The correct way to achieve this is:
sourceGenerators in Compile += execScript.taskValue
This will run the task every time before compiling your project. For this to work, your task must return a list of files it generates:
lazy val execScript = taskKey[Seq[File]]("Execute the shell script")
execScript := {
val outputDir := sourceManaged.in(Compile).value / "generated"
// bad: absolute local path
"C:/Users/dsweeney/Documents/configuration-services/swagger/codegen/SwaggerActivate.bat" !
// return all Java files of the output directory
outputDir ** "*.java" // or "*.scala"?
}
Note, it is good practice to generate the files into the sourceManaged
directory.
Upvotes: 1