How to prevent sbt from running a task multiple times in a session? -
i'd prevent next task getting run multiple times when sbt running:
val mytask = somesettings map {s => if !s.isdone dosomethingandsettheflag}
so what's expected when mytask run first time, isdone false , gets done in task, , task sets flag true. when task run sec time, since isdone flag true, skips actual execution block.
the expected behavior similar compile -> when source compiled, task doesn't compile code 1 time again next time it's triggered until watchsource task says code has been changed.
is possible? how?
this done sbt, task evaluated 1 time within single run. if want have value evaluated once, @ project load time, can alter settingkey.
this documented in sbt documentation (highlighting mine):
as mentioned in introduction, task evaluated on demand. each time sampletask invoked, example, print sum. if username changes between runs, stringtask take different values in separate runs. (within run, each task evaluated @ once.) in contrast, settings evaluated 1 time on project load , fixed until next reload.
sbt
No comments:
Post a Comment