A short post on how you might add your task to preform in chain with other tasks.
Previously there was a post on testing. Being able to automatically test code you write, especially if you are still learning, will definitely make up for time spent writing tests.
Key can be defined as one of 3 different types:
SettingsKey
on load
TaskKey
on call
InputKey
on call with arguments
Shorthand way to define them
TaskKey[Unit]("callTask") := {
println("doing something here")
}
Define a key separately from the task initialization.
lazy val someTask = taskKey[Unit]("task description")
someTask <<= taskDef
private def taskDef: Def.Initialize[Task[Unit]] = Def.task {
println("doing something here")
}
Tasks return values
TaskKey[Unit]("callTask") := {
2
}
Values are resolved as soon as they enter the scope.
To make a task depend on another task use Def.taskDyn
def superTask = Def.taskDyn{
if (shouldIcontinue.value) {
Def.task {
theContinuation.value
}
} else Def.task{}
}
Find a file defining your model. Should be placed in watch so the modification could trigger the task recall.
val curr =
watchSources
.value
.seq
.find(
_.getName
.contains("model.sql"))
.headOption
.foreach{
f => if (System.currentTimeMillis() - f.lastModified() < 9999)
createDB()
}