use of org.gradle.internal.DisplayName in project gradle by gradle.
the class JvmLocalLibraryMetaDataAdapter method createResolvedMetaData.
private DefaultLibraryLocalComponentMetadata createResolvedMetaData(BinarySpecInternal selectedBinary, String projectPath, EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage, EnumMap<UsageKind, List<PublishArtifact>> artifacts) {
final DefaultLibraryLocalComponentMetadata metadata = newResolvedLibraryMetadata(selectedBinary.getId(), toStringMap(dependenciesPerUsage), projectPath);
for (Map.Entry<UsageKind, List<PublishArtifact>> entry : artifacts.entrySet()) {
UsageKind usage = entry.getKey();
final List<PublishArtifact> publishArtifacts = entry.getValue();
metadata.addArtifacts(usage.getConfigurationName(), publishArtifacts);
metadata.addVariant(usage.getConfigurationName(), new OutgoingVariant() {
@Override
public DisplayName asDescribable() {
return Describables.of(metadata.getId());
}
@Override
public AttributeContainerInternal getAttributes() {
return ImmutableAttributes.EMPTY;
}
@Override
public Set<? extends PublishArtifact> getArtifacts() {
return new LinkedHashSet<PublishArtifact>(publishArtifacts);
}
@Override
public Set<? extends OutgoingVariant> getChildren() {
return ImmutableSet.of();
}
});
}
return metadata;
}
use of org.gradle.internal.DisplayName in project gradle by gradle.
the class UpgradeCapabilityResolver method resolve.
@Override
public void resolve(CapabilitiesConflictHandler.ResolutionDetails details) {
Collection<? extends Capability> capabilityVersions = details.getCapabilityVersions();
if (capabilityVersions.size() > 1) {
Set<Capability> sorted = Sets.newTreeSet((o1, o2) -> {
VersionNumber v1 = VersionNumber.parse(o1.getVersion());
VersionNumber v2 = VersionNumber.parse(o2.getVersion());
return v2.compareTo(v1);
});
sorted.addAll(capabilityVersions);
boolean first = true;
for (Capability capability : sorted) {
DisplayName reason = Describables.of("latest version of capability", ((CapabilityInternal) capability).getCapabilityId());
boolean isFirst = first;
details.getCandidates(capability).forEach(cand -> {
cand.byReason(reason);
if (!isFirst) {
cand.evict();
}
});
first = false;
}
}
}
use of org.gradle.internal.DisplayName in project gradle by gradle.
the class DefaultLocalComponentMetadataBuilder method addConfiguration.
@Override
public BuildableLocalConfigurationMetadata addConfiguration(BuildableLocalComponentMetadata metaData, ConfigurationInternal configuration) {
BuildableLocalConfigurationMetadata configurationMetadata = createConfiguration(metaData, configuration);
metaData.addDependenciesAndExcludesForConfiguration(configuration, configurationMetadataBuilder);
ComponentConfigurationIdentifier configurationIdentifier = new ComponentConfigurationIdentifier(metaData.getId(), configuration.getName());
configuration.collectVariants(new ConfigurationInternal.VariantVisitor() {
@Override
public void visitArtifacts(Collection<? extends PublishArtifact> artifacts) {
metaData.addArtifacts(configuration.getName(), artifacts);
}
@Override
public void visitOwnVariant(DisplayName displayName, ImmutableAttributes attributes, Collection<? extends Capability> capabilities, Collection<? extends PublishArtifact> artifacts) {
metaData.addVariant(configuration.getName(), configuration.getName(), configurationIdentifier, displayName, attributes, ImmutableCapabilities.of(capabilities), artifacts);
}
@Override
public void visitChildVariant(String name, DisplayName displayName, ImmutableAttributes attributes, Collection<? extends Capability> capabilities, Collection<? extends PublishArtifact> artifacts) {
metaData.addVariant(configuration.getName(), configuration.getName() + "-" + name, new NestedVariantIdentifier(configurationIdentifier, name), displayName, attributes, ImmutableCapabilities.of(capabilities), artifacts);
}
});
return configurationMetadata;
}
use of org.gradle.internal.DisplayName in project gradle by gradle.
the class DefaultResolvedComponentResult method getVariant.
@Override
@SuppressWarnings("deprecation")
public ResolvedVariantResult getVariant() {
if (variants.isEmpty()) {
return new DefaultResolvedVariantResult(componentId, Describables.of("<empty>"), ImmutableAttributes.EMPTY, Collections.emptyList(), null);
}
// Returns an approximation of a composite variant
List<String> parts = variants.stream().map(ResolvedVariantResult::getDisplayName).collect(Collectors.toList());
DisplayName variantName = new VariantNameBuilder().getVariantName(parts);
ResolvedVariantResult firstVariant = variants.get(0);
return new DefaultResolvedVariantResult(componentId, variantName, firstVariant.getAttributes(), firstVariant.getCapabilities(), null);
}
use of org.gradle.internal.DisplayName in project gradle by gradle.
the class TransformedProjectArtifactSet method visit.
@Override
public void visit(ArtifactVisitor visitor) {
DisplayName displayName = Describables.of(componentIdentifier);
for (TransformationNode node : transformedArtifacts) {
node.executeIfNotAlready();
Try<TransformationSubject> transformedSubject = node.getTransformedSubject();
if (transformedSubject.isSuccessful()) {
for (File file : transformedSubject.get().getFiles()) {
visitor.visitArtifact(displayName, targetAttributes, capabilities, node.getInputArtifact().transformedTo(file));
}
} else {
Throwable failure = transformedSubject.getFailure().get();
visitor.visitFailure(new TransformException(String.format("Failed to transform %s to match attributes %s.", node.getInputArtifact().getId().getDisplayName(), targetAttributes), failure));
}
}
visitor.endVisitCollection(this);
}
Aggregations