How does gradle merge extensions?


I can have a set some extension properties on the root project (using plugins.withType for exampe) and then define additional properties on the project itself and graldle will happily merge them all. Does anyone know how this is done? I tried navigating the source but with no success…