final List<ArtifactRepository> remoteRepositories = project.getRemoteArtifactRepositories();
request.setRemoteRepositories(remoteRepositories);
final ArtifactResolutionResult result = resolver.resolve(request);
if (result == null || !result.isSuccess()) {
new DefaultResolutionErrorHandler().throwErrors(request, result);
} else {
@SuppressWarnings("unchecked")
final Collection<? extends Artifact> resolvedArtifacts = (Set<? extends Artifact>)result.getArtifacts();
artifact = resolvedArtifacts.iterator().next();
}