scala - How to conditionally invoke a task in sbt? -


say taska heavy task should invoked if it's enabled , taskaenabled corresponding setting key.

a naive approach be:

val taskaconditional = def.task {   (taskaenabled, taska) map { (taskaenabled, taska) =>      if (taskaenabled) taska.value   } } 

this won't work due sbt design. taska becomes dependency of taskaconditional, executed regardless of if logic (i.e. taskaenabled ignored).

is there way can achieve want? (i can't change taska it's imported somewhere else)

in sbt 0.13.x can use dynamic computations def.taskdyn:

val taskaconditional = def.taskdyn {   if (taskaenabled.value) def.task {      taska.value // `.value` macro extract result of taska (execute it) if taskaenabled.value == true   }  } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -