How to modify an existing SBT task conditionally

I want to modify a task publish

and execute it conditionally (0.13.8). Here's what I tried (simplified):

publish := {
  Def.taskDyn {
    if (true) {
      Def.task {
        publish.value
      }
    } else {
      Def.task()
    }
  }.value
}

      

This fails with the following exception:

[error] (root/*:publish) sbt.Init$RuntimeUndefined: References to undefined settings at runtime.

      

Any ideas?

+3


source to share


1 answer


Try the following:



publish := {
    if( true ) {
        publish
    } else Def.task {
        println("something else")
    }
}.value

      

+3


source







All Articles