Search in sources :

Example 16 with Instantiator

use of org.gradle.internal.reflect.Instantiator in project gradle by gradle.

the class DefaultDomainObjectCollectionFactory method container.

private <T> NamedDomainObjectContainer<T> container(Class<T> elementType, InstanceGenerator elementInstantiator) {
    ReflectiveNamedDomainObjectFactory<T> objectFactory = new ReflectiveNamedDomainObjectFactory<T>(elementType, elementInstantiator);
    Instantiator instantiator = instantiatorFactory.decorateLenient();
    return Cast.uncheckedCast(instantiator.newInstance(FactoryNamedDomainObjectContainer.class, elementType, instantiator, new DynamicPropertyNamer(), objectFactory, mutationGuard, collectionCallbackActionDecorator));
}
Also used : ReflectiveNamedDomainObjectFactory(org.gradle.api.internal.ReflectiveNamedDomainObjectFactory) DynamicPropertyNamer(org.gradle.api.internal.DynamicPropertyNamer) FactoryNamedDomainObjectContainer(org.gradle.api.internal.FactoryNamedDomainObjectContainer) Instantiator(org.gradle.internal.reflect.Instantiator)

Example 17 with Instantiator

use of org.gradle.internal.reflect.Instantiator in project gradle by gradle.

the class DefaultScript method init.

@Override
public void init(final Object target, ServiceRegistry services) {
    super.init(target, services);
    this.scriptServices = services;
    loggingManager = services.get(LoggingManager.class);
    if (target instanceof HasScriptServices) {
        HasScriptServices scriptServices = (HasScriptServices) target;
        fileOperations = scriptServices.getFileOperations();
        processOperations = scriptServices.getProcessOperations();
    } else {
        Instantiator instantiator = services.get(Instantiator.class);
        FileLookup fileLookup = services.get(FileLookup.class);
        FileCollectionFactory fileCollectionFactory = services.get(FileCollectionFactory.class);
        File sourceFile = getScriptSource().getResource().getLocation().getFile();
        if (sourceFile != null) {
            FileResolver resolver = fileLookup.getFileResolver(sourceFile.getParentFile());
            FileCollectionFactory fileCollectionFactoryWithBase = fileCollectionFactory.withResolver(resolver);
            fileOperations = DefaultFileOperations.createSimple(resolver, fileCollectionFactoryWithBase, services);
            processOperations = services.get(ExecFactory.class).forContext().withFileResolver(resolver).withFileCollectionFactory(fileCollectionFactoryWithBase).withInstantiator(instantiator).withObjectFactory(new InstantiatorBackedObjectFactory(instantiator)).build();
        } else {
            fileOperations = DefaultFileOperations.createSimple(fileLookup.getFileResolver(), fileCollectionFactory, services);
            processOperations = services.get(ExecFactory.class);
        }
    }
    providerFactory = services.get(ProviderFactory.class);
}
Also used : ExecFactory(org.gradle.process.internal.ExecFactory) InstantiatorBackedObjectFactory(org.gradle.api.internal.model.InstantiatorBackedObjectFactory) ProviderFactory(org.gradle.api.provider.ProviderFactory) LoggingManager(org.gradle.api.logging.LoggingManager) Instantiator(org.gradle.internal.reflect.Instantiator) FileResolver(org.gradle.api.internal.file.FileResolver) FileLookup(org.gradle.api.internal.file.FileLookup) File(java.io.File) HasScriptServices(org.gradle.api.internal.file.HasScriptServices) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory)

Aggregations

Instantiator (org.gradle.internal.reflect.Instantiator)17 FileResolver (org.gradle.api.internal.file.FileResolver)4 RepositoryTransport (org.gradle.api.internal.artifacts.repositories.transport.RepositoryTransport)3 FileSystem (org.gradle.internal.nativeintegration.filesystem.FileSystem)3 File (java.io.File)2 ComponentMetadataListerDetails (org.gradle.api.artifacts.ComponentMetadataListerDetails)2 ComponentMetadataSupplierDetails (org.gradle.api.artifacts.ComponentMetadataSupplierDetails)2 MavenMetadataLoader (org.gradle.api.internal.artifacts.repositories.maven.MavenMetadataLoader)2 IvyResolver (org.gradle.api.internal.artifacts.repositories.resolver.IvyResolver)2 MavenResolver (org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver)2 CopyActionExecuter (org.gradle.api.internal.file.copy.CopyActionExecuter)2 ProviderFactory (org.gradle.api.provider.ProviderFactory)2 URI (java.net.URI)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 DefaultPolymorphicDomainObjectContainer (org.gradle.api.internal.DefaultPolymorphicDomainObjectContainer)1 DocumentationRegistry (org.gradle.api.internal.DocumentationRegistry)1 DynamicPropertyNamer (org.gradle.api.internal.DynamicPropertyNamer)1 FactoryNamedDomainObjectContainer (org.gradle.api.internal.FactoryNamedDomainObjectContainer)1 ReflectiveNamedDomainObjectFactory (org.gradle.api.internal.ReflectiveNamedDomainObjectFactory)1 ComponentMetadataProcessor (org.gradle.api.internal.artifacts.ComponentMetadataProcessor)1