I'm writing a plugin in which do something like the following:
project.extensions.create('myExtension', new MyExtension(project))
where MyExtension is the class that defines my new functionality.
Now, in gradle.build I can do this:
myExtension {
// configure cool stuff
}
What I would like to do now, is to "consume" a couple of the things in this configure closure, and pass the rest of the closure as-is to a task I defined, using project.configure(myTask, closure). However, I have no idea how to
Access the configure closure from the MyExtension class.
"Consume" some of the closure, i.e. access some of the properties on the closure and then strip them, leaving another closure which has all the untouched things but nothing else
Any pointers would be greatly appreciated =)
It's not how extensions work. The closure gets evaluated immediately in order to configure the extension object. After that, the closure is gone. Typically, a plugin will use the (information contained in the) extension object to further configure tasks.
PS: It's extensions.create('myExtension', MyExtension, project), not project.extensions.create('myExtension', new MyExtension(project)).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With