use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class DependenciesAwareVersionCatalogBuilder method collectDependencies.
private void collectDependencies(DependencySet allDependencies, Set<ModuleIdentifier> seen) {
for (Dependency dependency : allDependencies) {
String group = dependency.getGroup();
String name = dependency.getName();
if (group != null) {
ModuleIdentifier id = DefaultModuleIdentifier.newId(group, name);
if (seen.add(id)) {
String alias = explicitAliases.get(id);
if (alias != null) {
library(alias, group, name).version(v -> copyDependencyVersion(dependency, group, name, v));
} else {
tryGenericAlias(group, name, v -> copyDependencyVersion(dependency, group, name, v));
}
} else {
LOGGER.warn("Duplicate entry for dependency " + group + ":" + name);
}
}
}
}
use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class DefaultComponentSelectionRules method createSpecRuleActionFromId.
private SpecRuleAction<? super ComponentSelection> createSpecRuleActionFromId(Object id, RuleAction<? super ComponentSelection> ruleAction) {
final ModuleIdentifier moduleIdentifier;
try {
moduleIdentifier = moduleIdentifierNotationParser.parseNotation(id);
} catch (UnsupportedNotationException e) {
throw new InvalidUserCodeException(String.format(INVALID_SPEC_ERROR, id == null ? "null" : id.toString()), e);
}
Spec<ComponentSelection> spec = new ComponentSelectionMatchingSpec(moduleIdentifier);
return new SpecRuleAction<>(ruleAction, spec);
}
use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class ModuleForcingResolveRule method execute.
@Override
public void execute(DependencySubstitutionInternal details) {
if (forcedModules == null) {
return;
}
if (details.getRequested() instanceof ModuleComponentSelector) {
ModuleComponentSelector selector = (ModuleComponentSelector) details.getRequested();
ModuleIdentifier key = selector.getModuleIdentifier();
if (forcedModules.containsKey(key)) {
DefaultImmutableVersionConstraint versionConstraint = new DefaultImmutableVersionConstraint(forcedModules.get(key));
details.useTarget(newSelector(key, versionConstraint, selector.getAttributes(), selector.getRequestedCapabilities()), ComponentSelectionReasons.FORCED);
}
}
}
use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class Unions method tryModuleUnion.
private ExcludeSpec tryModuleUnion(ModuleExclude left, ExcludeSpec right) {
String leftModule = left.getModule();
if (right instanceof ModuleIdExclude) {
ModuleIdExclude mie = (ModuleIdExclude) right;
if (mie.getModuleId().getName().equals(leftModule)) {
return left;
}
}
if (right instanceof ModuleIdSetExclude) {
ModuleIdSetExclude ids = (ModuleIdSetExclude) right;
Set<ModuleIdentifier> items = ids.getModuleIds().stream().filter(id -> !id.getName().equals(leftModule)).collect(Collectors.toSet());
if (items.size() == 1) {
return factory.anyOf(left, factory.moduleId(items.iterator().next()));
}
if (items.isEmpty()) {
return left;
}
if (items.size() != ids.getModuleIds().size()) {
return factory.anyOf(left, factory.moduleIdSet(items));
}
}
return null;
}
use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.
the class Unions method tryGroupSetUnion.
private ExcludeSpec tryGroupSetUnion(GroupSetExclude left, ExcludeSpec right) {
Set<String> leftGroups = left.getGroups();
if (right instanceof ModuleIdExclude) {
ModuleIdExclude mie = (ModuleIdExclude) right;
if (leftGroups.contains(mie.getModuleId().getGroup())) {
return left;
}
}
if (right instanceof ModuleIdSetExclude) {
ModuleIdSetExclude ids = (ModuleIdSetExclude) right;
Set<ModuleIdentifier> items = ids.getModuleIds().stream().filter(id -> !leftGroups.contains(id.getGroup())).collect(Collectors.toSet());
if (items.size() == 1) {
return factory.anyOf(left, factory.moduleId(items.iterator().next()));
}
if (items.isEmpty()) {
return left;
}
if (items.size() != ids.getModuleIds().size()) {
return factory.anyOf(left, factory.moduleIdSet(items));
}
}
return null;
}
Aggregations