use of org.gradle.api.artifacts.result.ArtifactResolutionResult 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()));
}
});
}
Aggregations