Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbt does allow lazy dependencies #60

Closed
jroper opened this issue Mar 8, 2016 · 1 comment
Closed

sbt does allow lazy dependencies #60

jroper opened this issue Mar 8, 2016 · 1 comment

Comments

@jroper
Copy link

jroper commented Mar 8, 2016

The README says sbt doesn't allow lazy dependencies. This is false, sbt does so allow lazy dependencies:

val flag = taskKey[Boolean]("a flag")
val taskA = taskKey[Unit]("task a")
val taskB = taskKey[Unit]("task b")
val dependentTask = taskKey[Unit]("dependent task")

taskA := println("task a")
taskB := println("task b")
flag := true

dependentTask <<= (flag, taskA.task, taskB.task).flatMap { (flag, a, b) =>
  if (flag) a else b
}

Running it shows that tasks A and B are lazily depended on:

> dependentTask
task a
> set flag := false
> dependentTask
task b
> 
cvogt added a commit that referenced this issue Mar 8, 2016
cvogt added a commit that referenced this issue Mar 8, 2016
cvogt added a commit that referenced this issue Mar 8, 2016
Correcting readme according to #60
@cvogt
Copy link
Owner

cvogt commented Mar 8, 2016

@jroper thanks, good to now. Corrected in #61

For reference, here is the CBT equivalent

def flag = true
def a = println("task a")
def b = println("task b")
def dependentTask = if(flag) a else b

The question about how to dynamically replace flag with falsein CBT is still open. Right now it would take creating another build that's based on the original and overrides the member. Related issue is #62

@cvogt cvogt closed this as completed Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants