val = "hello"
val = "bye"
Where configurations is of type NamedObjectDomainContainer<MyType> and I have a NamedObjectDomainFactory<MyType>. and I create the container in my extension using project.container(Named..Container<MyType>, Named..Factory<MyType>)
What I don’t really understand is the Instantiator, any example I’ve seen of NamedObjectDomainContainer has some variation of the instatiator being used to create objects. If I implement a NamedObjectDomainFactory, why don’t I just make new objects using new MyType(name) instead of instantiator.newInstance(MyType.class, name)
It’s not part of the public API. In general, Gradle handles instantiating objects for you, and how that happens is an implementation detail. The NamedDomainObjectFactory interface is simply there if you want to provide the instantiation implementation. Otherwise, Gradle will simply look for a constructor with a single String argument which is used for the item’s name.