use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class IvyDependencyDescriptor method findMatches.
private void findMatches(ComponentIdentifier fromComponent, ComponentResolveMetadata targetComponent, String fromConfiguration, String patternConfiguration, String targetPattern, List<ConfigurationMetadata> targetConfigurations) {
int startFallback = targetPattern.indexOf('(');
if (startFallback >= 0) {
if (targetPattern.endsWith(")")) {
String preferred = targetPattern.substring(0, startFallback);
ConfigurationMetadata configuration = targetComponent.getConfiguration(preferred);
if (configuration != null) {
maybeAddConfiguration(targetConfigurations, configuration);
return;
}
targetPattern = targetPattern.substring(startFallback + 1, targetPattern.length() - 1);
}
}
if (targetPattern.equals("*")) {
for (String targetName : targetComponent.getConfigurationNames()) {
ConfigurationMetadata configuration = targetComponent.getConfiguration(targetName);
if (configuration.isVisible()) {
maybeAddConfiguration(targetConfigurations, configuration);
}
}
return;
}
if (targetPattern.equals("@")) {
targetPattern = patternConfiguration;
} else if (targetPattern.equals("#")) {
targetPattern = fromConfiguration;
}
ConfigurationMetadata configuration = targetComponent.getConfiguration(targetPattern);
if (configuration == null) {
throw new ConfigurationNotFoundException(fromComponent, fromConfiguration, targetPattern, targetComponent.getId());
}
maybeAddConfiguration(targetConfigurations, configuration);
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class IvyDependencyDescriptor method maybeAddConfiguration.
private void maybeAddConfiguration(List<ConfigurationMetadata> configurations, ConfigurationMetadata toAdd) {
Iterator<ConfigurationMetadata> iter = configurations.iterator();
while (iter.hasNext()) {
ConfigurationMetadata configuration = iter.next();
if (configuration.getHierarchy().contains(toAdd.getName())) {
// this configuration is a child of toAdd, so no need to add it
return;
}
if (toAdd.getHierarchy().contains(configuration.getName())) {
// toAdd is a child, so implies this configuration
iter.remove();
}
}
configurations.add(toAdd);
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class ResolvedArtifactsGraphVisitor method getArtifacts.
private ArtifactsForNode getArtifacts(DependencyGraphEdge dependency, DependencyGraphNode toConfiguration) {
ConfigurationMetadata targetConfiguration = toConfiguration.getMetadata();
ComponentResolveMetadata component = toConfiguration.getOwner().getMetadata();
ImmutableAttributes overriddenAttributes = dependency.getAttributes();
List<? extends ComponentArtifactMetadata> artifacts = dependency.getArtifacts(targetConfiguration);
if (!artifacts.isEmpty()) {
int id = nextId++;
ArtifactSet artifactSet = artifactSelector.resolveArtifacts(component, artifacts, overriddenAttributes);
return new ArtifactsForNode(id, artifactSet);
}
ArtifactsForNode configurationArtifactSet = artifactsByNodeId.get(toConfiguration.getNodeId());
if (configurationArtifactSet == null) {
ExcludeSpec exclusions = dependency.getExclusions();
ArtifactSet nodeArtifacts = artifactSelector.resolveArtifacts(component, targetConfiguration, exclusions, overriddenAttributes);
int id = nextId++;
configurationArtifactSet = new ArtifactsForNode(id, nodeArtifacts);
// Only share an ArtifactSet if the artifacts are not filtered by the dependency
if (!exclusions.mayExcludeArtifacts()) {
artifactsByNodeId.put(toConfiguration.getNodeId(), configurationArtifactSet);
}
}
return configurationArtifactSet;
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class AmbiguousConfigurationSelectionException method formatConfiguration.
static void formatConfiguration(TreeFormatter formatter, AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, List<? extends ConfigurationMetadata> matches, Set<String> requestedAttributes, final String conf) {
Optional<? extends ConfigurationMetadata> match = Iterables.tryFind(matches, new Predicate<ConfigurationMetadata>() {
@Override
public boolean apply(ConfigurationMetadata input) {
return conf.equals(input.getName());
}
});
if (match.isPresent()) {
AttributeContainer producerAttributes = match.get().getAttributes();
Set<Attribute<?>> targetAttributes = producerAttributes.keySet();
Set<String> targetAttributeNames = Sets.newTreeSet(Iterables.transform(targetAttributes, ATTRIBUTE_NAME));
Set<Attribute<?>> allAttributes = Sets.union(fromConfigurationAttributes.keySet(), producerAttributes.keySet());
Set<String> commonAttributes = Sets.intersection(requestedAttributes, targetAttributeNames);
Set<String> consumerOnlyAttributes = Sets.difference(requestedAttributes, targetAttributeNames);
formatter.node("Configuration '");
formatter.append(conf);
formatter.append("'");
formatter.startChildren();
List<Attribute<?>> sortedAttributes = Ordering.usingToString().sortedCopy(allAttributes);
formatAttributes(formatter, fromConfigurationAttributes, consumerSchema, producerAttributes, commonAttributes, consumerOnlyAttributes, sortedAttributes);
formatter.endChildren();
}
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class IvyDependencyMetadata method findMatches.
private void findMatches(ComponentResolveMetadata fromComponent, ComponentResolveMetadata targetComponent, String fromConfiguration, String patternConfiguration, String targetPattern, Set<ConfigurationMetadata> targetConfigurations) {
int startFallback = targetPattern.indexOf('(');
if (startFallback >= 0) {
if (targetPattern.endsWith(")")) {
String preferred = targetPattern.substring(0, startFallback);
ConfigurationMetadata configuration = targetComponent.getConfiguration(preferred);
if (configuration != null) {
targetConfigurations.add(configuration);
return;
}
targetPattern = targetPattern.substring(startFallback + 1, targetPattern.length() - 1);
}
}
if (targetPattern.equals("*")) {
for (String targetName : targetComponent.getConfigurationNames()) {
ConfigurationMetadata configuration = targetComponent.getConfiguration(targetName);
if (configuration.isVisible()) {
targetConfigurations.add(configuration);
}
}
return;
}
if (targetPattern.equals("@")) {
targetPattern = patternConfiguration;
} else if (targetPattern.equals("#")) {
targetPattern = fromConfiguration;
}
ConfigurationMetadata configuration = targetComponent.getConfiguration(targetPattern);
if (configuration == null) {
throw new ConfigurationNotFoundException(fromComponent.getComponentId(), fromConfiguration, targetPattern, targetComponent.getComponentId());
}
targetConfigurations.add(configuration);
}
Aggregations