suppose have 2 tasks, dostart
, dostop
, , want wrap existing task (e.g. test
) in these tasks. following not work:
test := def.sequential(dostart, test, dostop).value
it fails @ runtime error unresolved setting key. think quite natural, because def.sequential
expands nested sequence of def.taskdyn
, , since test
task referenced in middle task, "new" value requested, @ moment apparently unavailable:
test := def.taskdyn { dostart.value def.taskdyn { test.value dostop } }.value
if introduce temporary task , wrap instead of test
:
val _testoriginal = taskkey[unit]("used wrapping.") _testoriginal := test.value test := def.sequential(dostart, _testoriginal, dostop)
then not error seems infinite loop because dostart
executed sbt hangs indefinitely without invoking original test
task. seems natural because _testoriginal
depends on current value of test
, not original one.
the "solution" see introduce own tasks named testwrapped
, testquickwrapped
, etc. , tell users of build use them instead of test
/testquick
/etc., don't want it. so, how wrap existing task?
test := dostop.dependson(test.dependson(dostart)).value
though fyi, in case of tests, make dostart
, dostop
not tasks, rather vanilla functions, , use provided testoptions
facility.
testoptions in test += tests.setup(() => ...) testoptions in test += tests.cleanup(() => ... )
Comments
Post a Comment