Affect execution of dependency task

Is it possible to affect the execution of a dependency task to minimize code duplication? Something like this:

task a {
  doLast {
    println 'good' + project.text
  }
}

task b(dependsOn: a) {
  doFIrst {
    project.ext.set("text", "day")
  }
}

task c(dependsOn: a) {
  doFIrst {
    project.ext.set("text", "bye")
  }
}

b => goodday
c => goodbye

Or alternatively call a task from inside of another task?