use of org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingArtifactResolver in project gradle by gradle.
the class DefaultArtifactResolutionQuery method execute.
public ArtifactResolutionResult execute() {
if (componentType == null) {
throw new IllegalStateException("Must specify component type and artifacts to query.");
}
List<ResolutionAwareRepository> repositories = CollectionUtils.collect(repositoryHandler, Transformers.cast(ResolutionAwareRepository.class));
ResolutionStrategyInternal resolutionStrategy = configurationContainer.detachedConfiguration().getResolutionStrategy();
final ComponentResolvers componentResolvers = ivyFactory.create(resolutionStrategy, repositories, metadataHandler.getComponentMetadataProcessor());
final ComponentMetaDataResolver componentMetaDataResolver = componentResolvers.getComponentResolver();
final ArtifactResolver artifactResolver = new ErrorHandlingArtifactResolver(componentResolvers.getArtifactResolver());
return lockingManager.useCache(new Factory<ArtifactResolutionResult>() {
public ArtifactResolutionResult create() {
Set<ComponentResult> componentResults = Sets.newHashSet();
for (ComponentIdentifier componentId : componentIds) {
try {
ComponentIdentifier validId = validateComponentIdentifier(componentId);
componentResults.add(buildComponentResult(validId, componentMetaDataResolver, artifactResolver));
} catch (Throwable t) {
componentResults.add(new DefaultUnresolvedComponentResult(componentId, t));
}
}
return new DefaultArtifactResolutionResult(componentResults);
}
private ComponentIdentifier validateComponentIdentifier(ComponentIdentifier componentId) {
if (componentId instanceof ModuleComponentIdentifier) {
return componentId;
}
if (componentId instanceof ProjectComponentIdentifier) {
throw new IllegalArgumentException(String.format("Cannot query artifacts for a project component (%s).", componentId.getDisplayName()));
}
throw new IllegalArgumentException(String.format("Cannot resolve the artifacts for component %s with unsupported type %s.", componentId.getDisplayName(), componentId.getClass().getName()));
}
});
}
use of org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingArtifactResolver in project gradle by gradle.
the class DefaultArtifactDependencyResolver method resolve.
@Override
public void resolve(ResolveContext resolveContext, List<? extends ResolutionAwareRepository> repositories, GlobalDependencyResolutionRules metadataHandler, Spec<? super DependencyMetadata> edgeFilter, DependencyGraphVisitor graphVisitor, DependencyArtifactsVisitor artifactsVisitor, AttributesSchema attributesSchema, ImmutableModuleIdentifierFactory moduleIdentifierFactory, ModuleExclusions moduleExclusions) {
LOGGER.debug("Resolving {}", resolveContext);
ComponentResolvers resolvers = createResolvers(resolveContext, repositories, metadataHandler);
DependencyGraphBuilder builder = createDependencyGraphBuilder(resolvers, resolveContext.getResolutionStrategy(), metadataHandler, edgeFilter, attributesSchema, moduleIdentifierFactory, moduleExclusions);
ArtifactResolver artifactResolver = new ErrorHandlingArtifactResolver(new CacheLockingArtifactResolver(cacheLockingManager, resolvers.getArtifactResolver()));
BuildOperationExecutor buildOperationExecutor = serviceRegistry.get(BuildOperationExecutor.class);
DependencyGraphVisitor artifactsGraphVisitor = new ResolvedArtifactsGraphVisitor(artifactsVisitor, artifactResolver, attributesFactory, buildOperationExecutor, moduleExclusions);
// Resolve the dependency graph
builder.resolve(resolveContext, new CompositeDependencyGraphVisitor(graphVisitor, artifactsGraphVisitor));
}
Aggregations