I have a multi-project gradle build, where all subprojects of root project have common zip task. They should zip some source, depending of the subproject's settings.
First, I configured it in parent build.gradle:
subprojects { subproject ->
apply plugin: 'java'
...
task submission(type: Zip) {
destinationDir = subproject.buildDir
archiveName = subproject.name
from subproject.ext.submissionFiles
}
}
But this does not work with Cannot get property 'submissionFiles' on extra properties extension as it does not exist. So i moved the task in each subproject's build.gradle, which breaks DRY principle.
I think the problem is that the configuration phase takes place before subprojects are configured. How can I "defer" configuration of this task, so that I only configure ext.submissionFiles in subprojects?