Search in sources :

Example 1 with DisplayName

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DefaultLibraryLocalComponentMetadata(org.gradle.language.base.internal.model.DefaultLibraryLocalComponentMetadata) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal) OutgoingVariant(org.gradle.api.internal.artifacts.configurations.OutgoingVariant) DisplayName(org.gradle.internal.DisplayName) LinkedList(java.util.LinkedList) List(java.util.List) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) DefaultPublishArtifact(org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact) HashMap(java.util.HashMap) Map(java.util.Map) EnumMap(java.util.EnumMap)

Example 2 with DisplayName

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;
        }
    }
}
Also used : Capability(org.gradle.api.capabilities.Capability) DisplayName(org.gradle.internal.DisplayName) VersionNumber(org.gradle.util.internal.VersionNumber)

Example 3 with DisplayName

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;
}
Also used : ComponentConfigurationIdentifier(org.gradle.internal.component.model.ComponentConfigurationIdentifier) ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) DisplayName(org.gradle.internal.DisplayName) BuildableLocalConfigurationMetadata(org.gradle.internal.component.local.model.BuildableLocalConfigurationMetadata) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)

Example 4 with DisplayName

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);
}
Also used : ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) DisplayName(org.gradle.internal.DisplayName) VariantNameBuilder(org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.VariantNameBuilder)

Example 5 with DisplayName

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);
}
Also used : DisplayName(org.gradle.internal.DisplayName) File(java.io.File)

Aggregations

DisplayName (org.gradle.internal.DisplayName)10 InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)2 Capability (org.gradle.api.capabilities.Capability)2 UserCodeApplicationContext (org.gradle.configuration.internal.UserCodeApplicationContext)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 File (java.io.File)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)1 ResolvedVariantResult (org.gradle.api.artifacts.result.ResolvedVariantResult)1 AttributeContainer (org.gradle.api.attributes.AttributeContainer)1 ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)1 OutgoingVariant (org.gradle.api.internal.artifacts.configurations.OutgoingVariant)1 VariantNameBuilder (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.VariantNameBuilder)1