use of org.gradle.internal.component.model.ComponentArtifactMetadata in project gradle by gradle.
the class ProjectDependencyBuilder method determineTargetProjectPath.
private String determineTargetProjectPath(IdeProjectDependency dependency) {
ComponentArtifactMetadata eclipseProjectArtifact = ideProjectResolver.findArtifact(dependency.getProjectId(), "eclipse.project");
String targetProjectName = eclipseProjectArtifact == null ? dependency.getProjectName() : eclipseProjectArtifact.getName().getName();
return "/" + targetProjectName;
}
use of org.gradle.internal.component.model.ComponentArtifactMetadata 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.internal.component.model.ComponentArtifactMetadata in project gradle by gradle.
the class DefaultArtifactSet method toResolvedVariant.
private static ResolvedVariant toResolvedVariant(VariantResolveMetadata variant, ModuleVersionIdentifier ownerId, ModuleSource moduleSource, ModuleExclusion exclusions, ArtifactResolver artifactResolver, Map<ComponentArtifactIdentifier, ResolvableArtifact> allResolvedArtifacts, ArtifactTypeRegistry artifactTypeRegistry) {
List<? extends ComponentArtifactMetadata> artifacts = variant.getArtifacts();
ImmutableSet.Builder<ResolvableArtifact> resolvedArtifacts = ImmutableSet.builder();
// Apply any artifact type mappings to the attributes of the variant
ImmutableAttributes attributes = artifactTypeRegistry.mapAttributesFor(variant);
for (ComponentArtifactMetadata artifact : artifacts) {
IvyArtifactName artifactName = artifact.getName();
if (exclusions.excludeArtifact(ownerId.getModule(), artifactName)) {
continue;
}
ResolvableArtifact resolvedArtifact = allResolvedArtifacts.get(artifact.getId());
if (resolvedArtifact == null) {
Factory<File> artifactSource = new LazyArtifactSource(artifact, moduleSource, artifactResolver);
resolvedArtifact = new DefaultResolvedArtifact(ownerId, artifactName, artifact.getId(), artifact.getBuildDependencies(), artifactSource);
allResolvedArtifacts.put(artifact.getId(), resolvedArtifact);
}
resolvedArtifacts.add(resolvedArtifact);
}
return ArtifactBackedResolvedVariant.create(variant.asDescribable(), attributes, resolvedArtifacts.build());
}
use of org.gradle.internal.component.model.ComponentArtifactMetadata in project gradle by gradle.
the class DefaultArtifactResolutionQuery method addArtifacts.
private <T extends Artifact> void addArtifacts(DefaultComponentArtifactsResult artifacts, Class<T> type, ComponentResolveMetadata component, ArtifactResolver artifactResolver) {
BuildableArtifactSetResolveResult artifactSetResolveResult = new DefaultBuildableArtifactSetResolveResult();
artifactResolver.resolveArtifactsWithType(component, convertType(type), artifactSetResolveResult);
for (ComponentArtifactMetadata artifactMetaData : artifactSetResolveResult.getResult()) {
BuildableArtifactResolveResult resolveResult = new DefaultBuildableArtifactResolveResult();
artifactResolver.resolveArtifact(artifactMetaData, component.getSources(), resolveResult);
if (resolveResult.getFailure() != null) {
artifacts.addArtifact(new DefaultUnresolvedArtifactResult(artifactMetaData.getId(), type, resolveResult.getFailure()));
} else {
artifacts.addArtifact(ivyFactory.verifiedArtifact(new DefaultResolvedArtifactResult(artifactMetaData.getId(), ImmutableAttributes.EMPTY, Collections.emptyList(), Describables.of(component.getId().getDisplayName()), type, resolveResult.getResult())));
}
}
}
use of org.gradle.internal.component.model.ComponentArtifactMetadata in project gradle by gradle.
the class DefaultArtifactSet method toResolvedVariant.
public static ResolvedVariant toResolvedVariant(VariantResolveMetadata variant, ModuleVersionIdentifier ownerId, ModuleSources moduleSources, ExcludeSpec exclusions, ArtifactResolver artifactResolver, Map<ComponentArtifactIdentifier, ResolvableArtifact> allResolvedArtifacts, ImmutableAttributes variantAttributes, CalculatedValueContainerFactory calculatedValueContainerFactory) {
List<? extends ComponentArtifactMetadata> artifacts = variant.getArtifacts();
ImmutableSet.Builder<ResolvableArtifact> resolvedArtifacts = ImmutableSet.builder();
boolean hasExcludedArtifact = false;
for (ComponentArtifactMetadata artifact : artifacts) {
IvyArtifactName artifactName = artifact.getName();
if (exclusions.excludesArtifact(ownerId.getModule(), artifactName)) {
hasExcludedArtifact = true;
continue;
}
ResolvableArtifact resolvedArtifact = allResolvedArtifacts.get(artifact.getId());
if (resolvedArtifact == null) {
if (artifact.isOptionalArtifact()) {
DefaultBuildableArtifactResolveResult result = new DefaultBuildableArtifactResolveResult();
artifactResolver.resolveArtifact(artifact, moduleSources, result);
if (!result.isSuccessful()) {
// Optional artifact is not available
continue;
}
}
ValueCalculator<File> artifactCalculator;
if (artifactResolver instanceof ProjectArtifactResolver) {
artifactCalculator = ((ProjectArtifactResolver) artifactResolver).resolveArtifactLater(artifact);
} else {
// TODO - push this up to all ArtifactResolver implementations
artifactCalculator = new LazyArtifactSupplier(artifact, moduleSources, artifactResolver);
}
CalculatedValue<File> artifactSource = calculatedValueContainerFactory.create(Describables.of(artifact.getId()), artifactCalculator);
resolvedArtifact = new DefaultResolvableArtifact(ownerId, artifactName, artifact.getId(), context -> context.add(artifact.getBuildDependencies()), artifactSource, calculatedValueContainerFactory);
allResolvedArtifacts.put(artifact.getId(), resolvedArtifact);
}
resolvedArtifacts.add(resolvedArtifact);
}
VariantResolveMetadata.Identifier identifier = variant.getIdentifier();
if (hasExcludedArtifact) {
// An ad hoc variant, has no identifier
identifier = null;
}
return ArtifactBackedResolvedVariant.create(identifier, variant.asDescribable(), variantAttributes, withImplicitCapability(variant, ownerId), resolvedArtifacts.build());
}
Aggregations