use of org.gradle.api.artifacts.ResolvedArtifact in project gradle by gradle.
the class DefaultIdeDependencyResolver method getIdeRepoFileDependencies.
/**
* Gets IDE repository file dependencies.
*
* @param configuration Configuration
* @return IDE repository file dependencies
*/
public List<IdeExtendedRepoFileDependency> getIdeRepoFileDependencies(Configuration configuration) {
ResolutionResult result = getIncomingResolutionResult(configuration);
final Set<ResolvedComponentResult> resolvedRepoFileComponents = CollectionUtils.filter(result.getAllComponents(), new Spec<ResolvedComponentResult>() {
@Override
public boolean isSatisfiedBy(ResolvedComponentResult element) {
return element.getId() instanceof ModuleComponentIdentifier;
}
});
Set<ModuleVersionIdentifier> mappedResolvedDependencies = mapResolvedDependencies(resolvedRepoFileComponents);
Set<ResolvedArtifact> artifacts = getExternalArtifacts(configuration);
List<IdeExtendedRepoFileDependency> externalDependencies = new ArrayList<IdeExtendedRepoFileDependency>();
for (ResolvedArtifact artifact : artifacts) {
if (mappedResolvedDependencies.contains(artifact.getModuleVersion().getId())) {
IdeExtendedRepoFileDependency ideRepoFileDependency = new IdeExtendedRepoFileDependency(artifact.getFile());
ideRepoFileDependency.setId(artifact.getModuleVersion().getId());
externalDependencies.add(ideRepoFileDependency);
}
}
return externalDependencies;
}
use of org.gradle.api.artifacts.ResolvedArtifact in project flyway by flyway.
the class AbstractFlywayTask method addDependenciesWithScope.
private void addDependenciesWithScope(List<URL> urls, String scope) throws IOException {
for (ResolvedArtifact artifact : getProject().getConfigurations().getByName(scope).getResolvedConfiguration().getResolvedArtifacts()) {
URL artifactUrl = artifact.getFile().toURI().toURL();
getLogger().debug("Adding Dependency to Classpath: " + artifactUrl);
urls.add(artifactUrl);
}
}
use of org.gradle.api.artifacts.ResolvedArtifact in project gradle by gradle.
the class DefaultResolvedDependency method getAllArtifacts.
public Set<ResolvedArtifact> getAllArtifacts(ResolvedDependency parent) {
if (allArtifactsCache.get(parent) == null) {
Set<ResolvedArtifact> allArtifacts = new LinkedHashSet<ResolvedArtifact>();
allArtifacts.addAll(getArtifacts(parent));
for (ResolvedDependency childResolvedDependency : getChildren()) {
for (ResolvedDependency childParent : childResolvedDependency.getParents()) {
allArtifacts.addAll(childResolvedDependency.getAllArtifacts(childParent));
}
}
allArtifactsCache.put(parent, allArtifacts);
}
return allArtifactsCache.get(parent);
}
use of org.gradle.api.artifacts.ResolvedArtifact in project gradle by gradle.
the class DefaultArtifactSet method snapshot.
@Override
public ArtifactSet snapshot() {
ImmutableSet.Builder<ResolvedVariant> result = ImmutableSet.builder();
for (VariantMetadata variant : variants) {
Set<? extends ComponentArtifactMetadata> artifacts = variant.getArtifacts();
Set<ResolvedArtifact> resolvedArtifacts = new LinkedHashSet<ResolvedArtifact>(artifacts.size());
// Add artifact format as an implicit attribute when all artifacts have the same format
AttributeContainerInternal attributes = variant.getAttributes();
if (!attributes.contains(ArtifactAttributes.ARTIFACT_FORMAT)) {
String format = null;
for (ComponentArtifactMetadata artifact : artifacts) {
String candidateFormat = artifact.getName().getType();
if (format == null) {
format = candidateFormat;
} else if (!format.equals(candidateFormat)) {
format = null;
break;
}
}
if (format != null) {
attributes = attributesFactory.concat(attributes.asImmutable(), ArtifactAttributes.ARTIFACT_FORMAT, format);
}
}
for (ComponentArtifactMetadata artifact : artifacts) {
IvyArtifactName artifactName = artifact.getName();
if (exclusions.excludeArtifact(moduleVersionIdentifier.getModule(), artifactName)) {
continue;
}
ResolvedArtifact resolvedArtifact = allResolvedArtifacts.get(artifact.getId());
if (resolvedArtifact == null) {
Factory<File> artifactSource = new BuildOperationArtifactSource(buildOperationExecutor, artifact.getId(), new LazyArtifactSource(artifact, moduleSource, artifactResolver));
resolvedArtifact = new DefaultResolvedArtifact(moduleVersionIdentifier, artifactName, artifact.getId(), artifact.getBuildDependencies(), artifactSource);
allResolvedArtifacts.put(artifact.getId(), resolvedArtifact);
}
resolvedArtifacts.add(resolvedArtifact);
}
result.add(ArtifactBackedResolvedVariant.create(attributes, resolvedArtifacts));
}
return new ArtifactSetSnapshot(id, componentIdentifier, result.build());
}
use of org.gradle.api.artifacts.ResolvedArtifact in project gradle by gradle.
the class DependencyResolvingClasspath method getFiles.
@Override
public Set<File> getFiles() {
ensureResolved(true);
final Set<File> result = new LinkedHashSet<File>();
resolveResult.artifactsResults.getArtifacts().visit(new ArtifactVisitor() {
@Override
public void visitArtifact(AttributeContainer variant, ResolvedArtifact artifact) {
result.add(artifact.getFile());
}
@Override
public void visitFailure(Throwable failure) {
throw UncheckedException.throwAsUncheckedException(failure);
}
@Override
public boolean includeFiles() {
return true;
}
@Override
public void visitFile(ComponentArtifactIdentifier artifactIdentifier, AttributeContainer variant, File file) {
result.add(file);
}
});
return result;
}
Aggregations