nadavwr
nadavwr

Reputation: 1830

define setting only if a condition is met

Question regarding conditional settings. I'm trying to have a setting defined only if a certain condition is met:

lazy val proj = project .settings(/*other settings...*/) .settings((if (condition) Seq(foo := bar.value) else Seq.empty): _*)

Except, my code would really look more legible if I could do this on individual setting basis, e.g.:

project.settings( // other settings... if (condition) (foo := bar.value) else (hole := Nil) // other settings... )

Is there any neat and accepted way of accomplishing this? what would be a good candidate for a "monoidal zero" setting?

Upvotes: 0

Views: 70

Answers (1)

cchantep
cchantep

Reputation: 9158

You can use .configure

val prj = project.settings(...).configure { p =>
  if (foo) {
    p.settings(...)
  } else p
}

Upvotes: 2

Related Questions