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));
}
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);
}
Aggregations