use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class NoMatchingConfigurationSelectionException method generateMessage.
private static String generateMessage(AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, ComponentResolveMetadata targetComponent, List<String> configurationNames) {
List<ConfigurationMetadata> configurations = new ArrayList<ConfigurationMetadata>(configurationNames.size());
for (String name : configurationNames) {
ConfigurationMetadata targetComponentConfiguration = targetComponent.getConfiguration(name);
if (targetComponentConfiguration.isCanBeConsumed() && !targetComponentConfiguration.getAttributes().isEmpty()) {
configurations.add(targetComponentConfiguration);
}
}
Set<String> requestedAttributes = Sets.newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME));
TreeFormatter formatter = new TreeFormatter();
formatter.node("Unable to find a matching configuration in " + targetComponent.getComponentId().getDisplayName());
formatter.startChildren();
if (configurations.isEmpty()) {
formatter.node("None of the consumable configurations have attributes.");
} else {
// to make sure the output is consistently the same between invocations
for (String config : configurationNames) {
formatConfiguration(formatter, fromConfigurationAttributes, consumerSchema, configurations, requestedAttributes, config);
}
}
formatter.endChildren();
return formatter.toString();
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class MavenDependencyMetadata method selectConfigurations.
@Override
public Set<ConfigurationMetadata> selectConfigurations(ComponentResolveMetadata fromComponent, ConfigurationMetadata fromConfiguration, ComponentResolveMetadata targetComponent, AttributesSchema attributesSchema) {
Set<ConfigurationMetadata> result = Sets.newLinkedHashSet();
boolean requiresCompile = fromConfiguration.getName().equals("compile");
if (!requiresCompile) {
// From every configuration other than compile, include both the runtime and compile dependencies
ConfigurationMetadata runtime = findTargetConfiguration(fromComponent, fromConfiguration, targetComponent, "runtime");
result.add(runtime);
requiresCompile = !runtime.getHierarchy().contains("compile");
}
if (requiresCompile) {
// From compile configuration, or when the target's runtime configuration does not extend from compile, include the compile dependencies
result.add(findTargetConfiguration(fromComponent, fromConfiguration, targetComponent, "compile"));
}
ConfigurationMetadata master = targetComponent.getConfiguration("master");
if (master != null && (!master.getDependencies().isEmpty() || !master.getArtifacts().isEmpty())) {
result.add(master);
}
return result;
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class DefaultResolvedArtifactsBuilder method visitArtifacts.
@Override
public void visitArtifacts(DependencyGraphNode from, DependencyGraphNode to, ArtifactSet artifacts) {
if (sortOrder != ResolutionStrategy.SortOrder.DEFAULT) {
sortedNodeIds.get(to.getNodeId()).add(artifacts);
} else {
artifactSets.put(artifacts.getId(), artifacts);
}
// Don't collect build dependencies if not required
if (!buildProjectDependencies) {
return;
}
if (buildableArtifactSets.contains(artifacts.getId())) {
return;
}
// Collect the build dependencies in 2 steps: collect the artifact sets while traversing and at the end of traversal unpack the build dependencies for each
// We need to discard the artifact sets to avoid keeping strong references
ConfigurationMetadata configurationMetadata = to.getMetadata();
if (!(configurationMetadata instanceof LocalConfigurationMetadata)) {
return;
}
if (from.getOwner().getComponentId() instanceof ProjectComponentIdentifier) {
// This is here to attempt to leave out build dependencies that would cause a cycle in the task graph for the current build, so that the cross-build cycle detection kicks in. It's not fully correct
ProjectComponentIdentifier incomingId = (ProjectComponentIdentifier) from.getOwner().getComponentId();
if (!incomingId.getBuild().isCurrentBuild()) {
return;
}
}
buildableArtifactSets.add(artifacts.getId());
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class DefaultResolvedArtifactsBuilder method visitArtifacts.
@Override
public void visitArtifacts(DependencyGraphNode from, DependencyGraphNode to, int artifactSetId, ArtifactSet artifacts) {
// Don't collect build dependencies if not required
if (!buildProjectDependencies) {
artifacts = new NoBuildDependenciesArtifactSet(artifacts);
} else {
ConfigurationMetadata configurationMetadata = to.getMetadata();
if (configurationMetadata instanceof LocalConfigurationMetadata) {
// For a dependency from _another_ build to _this_ build, don't make the artifact buildable
// Making these artifacts buildable leads to poor error reporting due to direct task dependency cycle (losing the intervening build dependencies)
ComponentIdentifier incomingId = from.getOwner().getComponentId();
ComponentIdentifier outgoingId = to.getOwner().getComponentId();
if (incomingId instanceof ProjectComponentIdentifier && outgoingId instanceof ProjectComponentIdentifier) {
if (!isCurrentBuild(incomingId) && isCurrentBuild(outgoingId)) {
artifacts = new NoBuildDependenciesArtifactSet(artifacts);
}
}
}
}
collectArtifacts(artifactSetId, artifacts);
}
use of org.gradle.internal.component.model.ConfigurationMetadata in project gradle by gradle.
the class AmbiguousConfigurationSelectionException method generateMessage.
private static String generateMessage(AttributeContainerInternal fromConfigurationAttributes, AttributeMatcher attributeMatcher, List<? extends ConfigurationMetadata> matches, ComponentResolveMetadata targetComponent) {
Map<String, ConfigurationMetadata> ambiguousConfigurations = new TreeMap<String, ConfigurationMetadata>();
for (ConfigurationMetadata match : matches) {
ambiguousConfigurations.put(match.getName(), match);
}
TreeFormatter formatter = new TreeFormatter();
formatter.node("Cannot choose between the following configurations of ");
formatter.append(targetComponent.getId().getDisplayName());
formatter.startChildren();
for (String configuration : ambiguousConfigurations.keySet()) {
formatter.node(configuration);
}
formatter.endChildren();
formatter.node("All of them match the consumer attributes");
// We're sorting the names of the configurations and later attributes
// to make sure the output is consistently the same between invocations
formatter.startChildren();
for (ConfigurationMetadata ambiguousConf : ambiguousConfigurations.values()) {
formatConfiguration(formatter, fromConfigurationAttributes, attributeMatcher, ambiguousConf);
}
formatter.endChildren();
return formatter.toString();
}
Aggregations