use of org.gradle.internal.reflect.Instantiator in project gradle by gradle.
the class DefaultWorkerServer method execute.
@Override
public DefaultWorkResult execute(SimpleActionExecutionSpec<?> spec) {
try {
Class<? extends WorkAction<?>> implementationClass = Cast.uncheckedCast(spec.getImplementationClass());
// Exceptions to services available for injection
Spec<Class<?>> whiteListPolicy;
if (spec.isInternalServicesRequired()) {
whiteListPolicy = element -> true;
} else {
whiteListPolicy = element -> false;
}
ServiceLookup instantiationServices = isolationScheme.servicesForImplementation(spec.getParameters(), internalServices, additionalWhitelistedServices, whiteListPolicy);
Instantiator instantiator = instantiatorFactory.inject(instantiationServices);
WorkAction<?> execution;
if (ProvidesWorkResult.class.isAssignableFrom(implementationClass)) {
execution = instantiator.newInstance(implementationClass, spec.getParameters(), instantiator);
} else {
execution = instantiator.newInstance(implementationClass);
}
execution.execute();
if (execution instanceof ProvidesWorkResult) {
return ((ProvidesWorkResult) execution).getWorkResult();
} else {
return DefaultWorkResult.SUCCESS;
}
} catch (Throwable t) {
return new DefaultWorkResult(true, t);
}
}
use of org.gradle.internal.reflect.Instantiator in project gradle by gradle.
the class ResolveIvyFactory method create.
public ComponentResolvers create(String resolveContextName, ResolutionStrategyInternal resolutionStrategy, Collection<? extends ResolutionAwareRepository> repositories, ComponentMetadataProcessorFactory metadataProcessor, AttributeContainer consumerAttributes, AttributesSchema attributesSchema, ImmutableAttributesFactory attributesFactory, ComponentMetadataSupplierRuleExecutor componentMetadataSupplierRuleExecutor) {
if (repositories.isEmpty()) {
return new NoRepositoriesResolver();
}
CachePolicy cachePolicy = resolutionStrategy.getCachePolicy();
startParameterResolutionOverride.applyToCachePolicy(cachePolicy);
UserResolverChain moduleResolver = new UserResolverChain(versionComparator, resolutionStrategy.getComponentSelection(), versionParser, consumerAttributes, attributesSchema, attributesFactory, metadataProcessor, componentMetadataSupplierRuleExecutor, cachePolicy, calculatedValueContainerFactory);
ParentModuleLookupResolver parentModuleResolver = new ParentModuleLookupResolver(versionComparator, moduleIdentifierFactory, versionParser, consumerAttributes, attributesSchema, attributesFactory, metadataProcessor, componentMetadataSupplierRuleExecutor, cachePolicy, calculatedValueContainerFactory);
for (ResolutionAwareRepository repository : repositories) {
ConfiguredModuleComponentRepository baseRepository = repository.createResolver();
baseRepository.setComponentResolvers(parentModuleResolver);
Instantiator instantiator = baseRepository.getComponentMetadataInstantiator();
MetadataResolutionContext metadataResolutionContext = new DefaultMetadataResolutionContext(cachePolicy, instantiator);
ComponentMetadataProcessor componentMetadataProcessor = metadataProcessor.createComponentMetadataProcessor(metadataResolutionContext);
ModuleComponentRepository moduleComponentRepository = baseRepository;
if (baseRepository.isLocal()) {
moduleComponentRepository = new CachingModuleComponentRepository(moduleComponentRepository, cacheProvider.getInMemoryOnlyCaches(), cachePolicy, timeProvider, componentMetadataProcessor, ChangingValueDependencyResolutionListener.NO_OP);
moduleComponentRepository = new LocalModuleComponentRepository(moduleComponentRepository);
} else {
moduleComponentRepository = startParameterResolutionOverride.overrideModuleVersionRepository(moduleComponentRepository);
moduleComponentRepository = new CachingModuleComponentRepository(moduleComponentRepository, cacheProvider.getPersistentCaches(), cachePolicy, timeProvider, componentMetadataProcessor, listener);
}
moduleComponentRepository = cacheProvider.getResolvedArtifactCaches().provideResolvedArtifactCache(moduleComponentRepository, resolutionStrategy.isDependencyVerificationEnabled());
if (baseRepository.isDynamicResolveMode()) {
moduleComponentRepository = new IvyDynamicResolveModuleComponentRepository(moduleComponentRepository);
}
moduleComponentRepository = new ErrorHandlingModuleComponentRepository(moduleComponentRepository, repositoryBlacklister);
moduleComponentRepository = filterRepository(repository, moduleComponentRepository, resolveContextName, consumerAttributes);
moduleComponentRepository = dependencyVerificationOverride.overrideDependencyVerification(moduleComponentRepository, resolveContextName, resolutionStrategy);
moduleResolver.add(moduleComponentRepository);
parentModuleResolver.add(moduleComponentRepository);
}
return moduleResolver;
}
use of org.gradle.internal.reflect.Instantiator in project gradle by gradle.
the class DefaultFlatDirArtifactRepository method createRealResolver.
private IvyResolver createRealResolver() {
Set<File> dirs = getDirs();
if (dirs.isEmpty()) {
throw new InvalidUserDataException("You must specify at least one directory for a flat directory repository.");
}
RepositoryTransport transport = transportFactory.createFileTransport(getName());
Instantiator injector = createInjectorForMetadataSuppliers(transport, instantiatorFactory, null, null);
IvyResolver resolver = new IvyResolver(getName(), transport, locallyAvailableResourceFinder, false, artifactFileStore, null, null, createMetadataSources(), IvyMetadataArtifactProvider.INSTANCE, injector, checksumService);
for (File root : dirs) {
resolver.addArtifactLocation(root.toURI(), "/[artifact]-[revision](-[classifier]).[ext]");
resolver.addArtifactLocation(root.toURI(), "/[artifact](-[classifier]).[ext]");
}
return resolver;
}
use of org.gradle.internal.reflect.Instantiator in project gradle by gradle.
the class DefaultFileOperations method createSimple.
public static DefaultFileOperations createSimple(FileResolver fileResolver, FileCollectionFactory fileTreeFactory, ServiceRegistry services) {
Instantiator instantiator = services.get(Instantiator.class);
ObjectFactory objectFactory = services.get(ObjectFactory.class);
FileSystem fileSystem = services.get(FileSystem.class);
DirectoryFileTreeFactory directoryFileTreeFactory = services.get(DirectoryFileTreeFactory.class);
StreamHasher streamHasher = services.get(StreamHasher.class);
FileHasher fileHasher = services.get(FileHasher.class);
ApiTextResourceAdapter.Factory textResourceAdapterFactory = services.get(ApiTextResourceAdapter.Factory.class);
Factory<PatternSet> patternSetFactory = services.getFactory(PatternSet.class);
Deleter deleter = services.get(Deleter.class);
DocumentationRegistry documentationRegistry = services.get(DocumentationRegistry.class);
ProviderFactory providers = services.get(ProviderFactory.class);
DefaultResourceHandler.Factory resourceHandlerFactory = DefaultResourceHandler.Factory.from(fileResolver, fileSystem, null, textResourceAdapterFactory);
return new DefaultFileOperations(fileResolver, null, instantiator, directoryFileTreeFactory, streamHasher, fileHasher, resourceHandlerFactory, fileTreeFactory, objectFactory, fileSystem, patternSetFactory, deleter, documentationRegistry, providers);
}
use of org.gradle.internal.reflect.Instantiator in project gradle by gradle.
the class DefaultDomainObjectCollectionFactory method newPolymorphicDomainObjectContainer.
@Override
public <T> ExtensiblePolymorphicDomainObjectContainer<T> newPolymorphicDomainObjectContainer(Class<T> elementType) {
Instantiator instantiator = instantiatorFactory.decorateLenient();
Instantiator elementInstantiator = instantiatorFactory.decorateLenient(servicesToInject);
return Cast.uncheckedCast(instantiator.newInstance(DefaultPolymorphicDomainObjectContainer.class, elementType, instantiator, elementInstantiator, collectionCallbackActionDecorator));
}
Aggregations