I’m using a DefaultNamedDomainObjectSet in my plugin and I’d like to add a all(Closure) call to execute something against all objects added to the set. The problem is that the Closure passed into the all method is being run before configure closure used to configure the object being added to the DefaultNamedDomainObjectSet. E.g.
def container = project.container(CustomArtifact)
container.all {
println "Happens 1st"
// No idea what object will look like after configure at this point
}
project.extensions.custom = container
project {
custom {
'artifact' {
println 'Happens 2nd'
}
}
}
I really want to act upon objects going into the container immediately as they’re being added, yet I require them being configured first. It’s evident in AbstractNamedDomainObjectContainer.create that it adds the object (triggering the DefaultDomainObjectCollection.doAdd call backs) THEN configures it. Personally, I feel that this is broken, the concept of configure hints that it’s being configured immediately after the constructor. If this is the intended behavior, then the problem becomes that I don’t have a hook to see objects after they’re configured until I actually go to act on the container’s contents. Or am I missing something?