Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do modify an existing SBT task conditionally

Tags:

sbt

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?

like image 289
reikje Avatar asked Apr 27 '26 13:04

reikje


1 Answers

Try this:

publish := {
    if( true ) {
        publish
    } else Def.task {
        println("something else")
    }
}.value
like image 83
marios Avatar answered May 05 '26 02:05

marios



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!