Appliying a Custom Task from a seperate build file to all sub projects


(Ferghal Smyth) #1

Hi,

I want to create a custom task that is applied to all sub projects through a configure block.

The task exists at the root project level in a custom.gradle file.

class CustomTask extends DefaultTask {
 String customMessage
    @TaskAction
 def runMe() {println "Show $customMessage"}
}

I want to apply the custom build file to each subproject.

configure(
 subprojects.findAll {it.name !='someExclude'}) {
apply from: 'custom.gradle'
}

And have each subproject create a new task of this type passing some project specific information.

task doCustom( type: CustomTask ) {
     customMessage= 'customise'
 }