gradle-master/subprojects/docs/src/snippets/plugins/nestedObjects/groovy/buildSrc/src/main/java/DownloadExtension.java
import org.gradle.api.model.ObjectFactory;

import javax.inject.Inject;

// tag::download-extension[]
public class DownloadExtension {
    // A nested instance
    private final Resource resource;

    @Inject
    public DownloadExtension(ObjectFactory objectFactory) {
        // Use an injected ObjectFactory to create a Resource object
        resource = objectFactory.newInstance(Resource.class);
    }

    public Resource getResource() {
        return resource;
    }
}
// end::download-extension[]
