The idea is that these define JPA persistence-units and we want to collect the dependencies per unit.
I’ve looked at DependencyHandler but I am not sure how something like implementation 'a:b:c' gets mapped to the DependencyHandler#add call (assuming that is what it gets routed to).
class MyExtension {
private final PersistenceUnits persistenceUnits
public MyExtension(Project project) {
this.persistenceUnits = new PersistenceUnits(project)
}
public persistenceUnits(Closure closure) {
closure.setDelegate(persistenceUnits)
closure.setResolveStrategy(Closure.DELEGATE_FIRST)
closure.call()
}
// getter for third parties to hook into events
public PersistenceUnits getPersistenceUnits() {
returh this.persistenceUnits
}
}
class PersistenceUnits {
private final NamedDomainObjectCollection<Foo> foos
public PersistenceUnits(Project project) {
this.foos = project.objectFactory.namedDomainObjectSet(Foo.class)
}
def methodMissing(String name, args) {
// name will contain abc, args will contain the project
foos.doStuff(name)
}
// getter for third parties to hook into events
public NamedDomainObjectCollection<Foo> getFoos() {
return this.foos
}
}