use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class DefaultCapabilitiesConflictHandler method registerCandidate.
@Override
public PotentialConflict registerCandidate(CapabilitiesConflictHandler.Candidate candidate) {
CapabilityInternal capability = (CapabilityInternal) candidate.getCapability();
String group = capability.getGroup();
String name = capability.getName();
final Set<NodeState> nodes = findNodesFor(capability);
Collection<NodeState> implicitCapabilityProviders = candidate.getImplicitCapabilityProviders();
nodes.addAll(implicitCapabilityProviders);
NodeState node = candidate.getNode();
if (nodes.add(node) && nodes.size() > 1) {
// The registered nodes may contain nodes which are no longer selected.
// We don't remove them from the list in the first place because it proved to be
// slower than filtering as needed.
ModuleIdentifier rootId = null;
final List<NodeState> candidatesForConflict = Lists.newArrayListWithCapacity(nodes.size());
for (NodeState ns : nodes) {
if (ns.isSelected()) {
candidatesForConflict.add(ns);
if (ns.isRoot()) {
rootId = ns.getComponent().getId().getModule();
}
}
}
if (rootId != null && candidatesForConflict.size() > 1) {
// This is a special case for backwards compatibility: it is possible to have
// a cycle where the root component depends on a library which transitively
// depends on a different version of the root module. In this case, we effectively
// allow 2 modules to have the same capability, so we filter the nodes coming
// from transitive dependencies
ModuleIdentifier rootModuleId = rootId;
candidatesForConflict.removeIf(n -> !n.isRoot() && n.getComponent().getId().getModule().equals(rootModuleId));
}
if (candidatesForConflict.size() > 1) {
PotentialConflict conflict = new PotentialConflict() {
@Override
public void withParticipatingModules(Action<ModuleIdentifier> action) {
for (NodeState node : candidatesForConflict) {
action.execute(node.getComponent().getId().getModule());
}
}
@Override
public boolean conflictExists() {
return true;
}
};
conflicts.add(new CapabilityConflict(group, name, candidatesForConflict));
return conflict;
}
}
return PotentialConflictFactory.noConflict();
}
use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class ModuleComponentResolveMetadataSerializer method readModuleIdentifier.
private VirtualComponentIdentifier readModuleIdentifier(Decoder decoder) throws IOException {
String group = decoder.readString();
String module = decoder.readString();
String version = decoder.readString();
ModuleIdentifier moduleIdentifier = DefaultModuleIdentifier.newId(group, module);
return new DefaultVirtualModuleComponentIdentifier(moduleIdentifier, version);
}
use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class PgpKeyGrouper method groupByModuleId.
private void groupByModuleId(Map.Entry<String, Collection<PgpEntry>> e, List<ModuleIdentifier> moduleIds) {
ModuleIdentifier mi = moduleIds.get(0);
verificationsBuilder.addTrustedKey(e.getKey(), mi.getGroup(), mi.getName(), null, null, false);
markKeyDeclaredGlobally(e);
}
use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class ComponentModuleMetadataContainer method detectCycles.
private static void detectCycles(Map<ModuleIdentifier, Replacement> replacements, ModuleIdentifier source, ModuleIdentifier target) {
if (source.equals(target)) {
throw new InvalidUserDataException(String.format("Cannot declare module replacement that replaces self: %s->%s", source, target));
}
ModuleIdentifier m = unwrap(replacements.get(target));
if (m == null) {
// target does not exist in the map, there's no cycle for sure
return;
}
Set<ModuleIdentifier> visited = new LinkedHashSet<>();
visited.add(source);
visited.add(target);
while (m != null) {
if (!visited.add(m)) {
// module was already visited, there is a cycle
throw new InvalidUserDataException(format("Cannot declare module replacement %s->%s because it introduces a cycle: %s", source, target, Joiner.on("->").join(visited) + "->" + source));
}
m = unwrap(replacements.get(m));
}
}
use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class DependenciesAwareVersionCatalogBuilder method build.
@Override
public DefaultVersionCatalog build() {
if (shouldAmendModel) {
DependencySet allDependencies = dependenciesConfiguration.getAllDependencies();
DependencyConstraintSet allDependencyConstraints = dependenciesConfiguration.getAllDependencyConstraints();
Set<ModuleIdentifier> seen = Sets.newHashSet();
collectDependencies(allDependencies, seen);
collectConstraints(allDependencyConstraints, seen);
}
shouldAmendModel = false;
return super.build();
}
Aggregations