Execution time variable setting


(Ken Adey) #1

I’m trying to set a global variable at execution time to use depending on the selected task:

def taskName = ‘’

task taskA() {
taskName = 'taskA’
dependsOn “printTaskName”
}

task taskB() {
taskName = 'taskB’
dependsOn “printTaskName”
}

task printTaskName() {
println taskName
}

Thanks.


(Ken Adey) #2

Sorry, my original post was incomplete:

The above code does not work because the taskName assignments occur at configuration time.

I need a mechanism that changes the value of taskName at execution time.

Thanks again.