Reuse closure definition


(Ankit Goel) #1

I am a bit new to gradle. I have a following definition in the main project.
ext {

buildConfig = {

addons {
forStoreFronts(installAddonsForStoreFronts) {
names installAddonsNames
template installAddonsTemplate
}
}
}
}

In the subproject , i have the following task
task installAddons {

doLast {
    def pl = platform(buildConfig)

    pl.addons {
        forStoreFronts(installAddonsForStoreFronts) {
            names installAddonsNames
            template installAddonsTemplate
        }
        install()
    }
}

}

As you see there is some duplication with regards to addons closure. Is there anyway I could reuse from main project ? Help is appreciated.