Hello,
I am after some help with regards to using an exec task and it’s place in the lifecycle. We are trying to use the Git Gradle plugin to get the working branch name which is then used as part of an external execute (part of building a Delphi application). But we have some problems around the configuration and execution phases on the lifecycle. It could be because we’re just getting our hands truly dirty in the Gradle world.
Anyway, here is an example piece of code and some ideas on how to address this would be greatly appreciated:
task branchName(type: GitBranchList) {
branchType = GitBranchList.BranchType.LOCAL
project.ext["branch.name"] = "unknown"
doLast {
project.ext["branch.name"] = getWorkingBranch().name
}
}
task doSomeExecutable(type: Exec, dependsOn: ["branchName"]) {
commandLine "some-executable.exe", project.ext["branch.name"]
}
The above works…but it only ever passes in “unknown” as the parameter. Because “getWorkingBranch” is an execution phase only function and the Exec task is configuration phase, we’re facing a chicken and egg issue here.
Is there an appropriate approach to this problem?
Regards,
Wade