Ok, so maybe I need to do everything in tasks. Then use the task outputs to avoid specifying variables that are initally null. But this doesn’t work either:
@Override
public void apply(Project project) {
Task gbi = project.tasks.create("generateBuildInfo", DefaultTask) {
doFirst {
project.resources.text.fromString(generateBuildInfo(project)).asFile()
}
}
Task cbi = project.tasks.create("copyBuildInfo", Copy ) {
setDestinationDir(getDest(project))
from(gbi.outputs) {
rename { 'version.properties' }
}
}
cbi.dependsOn(gbi)
}
The gbi task executes but says “Task has not declared any outputs.” So then cbi won’t execute because it has no source files.
How does a task “declare” outputs?