Passing a parameter or variable from one task to another

I would appreciate any hint as how to pass something defined in one task to another task. For example, I have the following two tasks, taskA and taskB. I want to be pass “myValue” defined in taskB to taskA.

task TaskA ( ) {
doLast() {
println "The value of myValue = " + myValue
}
}

task TaskB () {
def myValue
myValue = project.getPropert(“myProp”) + “test” // this just a simple test. The real world this could be some complex calculation using multiple properties …

}

I have tried dependsOn and finalizedBy relationship between taskA and taskB. Just cannot get it to work.