reikje
reikje

Reputation: 3064

How do modify an existing SBT task conditionally

I want to modify the publish task and execute it conditionally (0.13.8). Here is 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?

Upvotes: 3

Views: 227

Answers (1)

marios
marios

Reputation: 8996

Try this:

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

Upvotes: 3

Related Questions