use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class RealisedIvyModuleResolveMetadata method withDynamicConstraintVersions.
@Override
public IvyModuleResolveMetadata withDynamicConstraintVersions() {
ImmutableList<IvyDependencyDescriptor> descriptors = getDependencies();
if (descriptors.isEmpty()) {
return this;
}
Map<IvyDependencyDescriptor, IvyDependencyDescriptor> transformedDescriptors = Maps.newHashMapWithExpectedSize(descriptors.size());
for (IvyDependencyDescriptor dependency : descriptors) {
ModuleComponentSelector selector = dependency.getSelector();
String dynamicConstraintVersion = dependency.getDynamicConstraintVersion();
ModuleComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(selector.getModuleIdentifier(), dynamicConstraintVersion);
transformedDescriptors.put(dependency, dependency.withRequested(newSelector));
}
return this.withDependencies(transformedDescriptors);
}
use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class LazyToRealisedModuleComponentResolveMetadataHelper method convertDependencies.
private static List<GradleDependencyMetadata> convertDependencies(List<? extends ComponentVariant.Dependency> dependencies, List<? extends ComponentVariant.DependencyConstraint> dependencyConstraints, boolean force) {
List<GradleDependencyMetadata> result = new ArrayList<>(dependencies.size());
for (ComponentVariant.Dependency dependency : dependencies) {
ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(dependency.getGroup(), dependency.getModule()), dependency.getVersionConstraint(), dependency.getAttributes(), dependency.getRequestedCapabilities());
List<ExcludeMetadata> excludes = dependency.getExcludes();
result.add(new GradleDependencyMetadata(selector, excludes, false, dependency.isEndorsingStrictVersions(), dependency.getReason(), force, dependency.getDependencyArtifact()));
}
for (ComponentVariant.DependencyConstraint dependencyConstraint : dependencyConstraints) {
result.add(new GradleDependencyMetadata(DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(dependencyConstraint.getGroup(), dependencyConstraint.getModule()), dependencyConstraint.getVersionConstraint(), dependencyConstraint.getAttributes(), ImmutableList.of()), Collections.emptyList(), true, false, dependencyConstraint.getReason(), force, null));
}
return result;
}
use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class RealisedMavenModuleResolveMetadataSerializationHelper method readMavenDependency.
private MavenDependencyDescriptor readMavenDependency(Decoder decoder, Map<Integer, MavenDependencyDescriptor> deduplicationDependencyCache) throws IOException {
int mapping = decoder.readSmallInt();
if (mapping == deduplicationDependencyCache.size()) {
ModuleComponentSelector requested = getComponentSelectorSerializer().read(decoder);
IvyArtifactName artifactName = readNullableArtifact(decoder);
List<ExcludeMetadata> mavenExcludes = readMavenExcludes(decoder);
MavenScope scope = MavenScope.values()[decoder.readSmallInt()];
MavenDependencyType type = MavenDependencyType.values()[decoder.readSmallInt()];
MavenDependencyDescriptor mavenDependencyDescriptor = new MavenDependencyDescriptor(scope, type, requested, artifactName, mavenExcludes);
deduplicationDependencyCache.put(mapping, mavenDependencyDescriptor);
return mavenDependencyDescriptor;
} else {
MavenDependencyDescriptor mavenDependencyDescriptor = deduplicationDependencyCache.get(mapping);
assert mavenDependencyDescriptor != null;
return mavenDependencyDescriptor;
}
}
use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class RenderableUnresolvedDependencyResult method getName.
@Override
public String getName() {
ComponentSelector requested = dependency.getRequested();
ComponentSelector attempted = dependency.getAttempted();
if (requested.equals(attempted)) {
return requested.getDisplayName();
}
if (requested instanceof ModuleComponentSelector && attempted instanceof ModuleComponentSelector) {
ModuleComponentSelector requestedSelector = (ModuleComponentSelector) requested;
ModuleComponentSelector attemptedSelector = (ModuleComponentSelector) attempted;
if (requestedSelector.getGroup().equals(attemptedSelector.getGroup()) && requestedSelector.getModule().equals(attemptedSelector.getModule())) {
return requested.getDisplayName() + " -> " + attemptedSelector.getVersionConstraint().getDisplayName();
}
}
return requested.getDisplayName() + " -> " + attempted.getDisplayName();
}
use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class DependencyResultSpec method matchesRequested.
private boolean matchesRequested(DependencyResult candidate) {
ComponentSelector requested = candidate.getRequested();
if (requested instanceof ModuleComponentSelector) {
ModuleComponentSelector requestedModule = (ModuleComponentSelector) requested;
String requestedCandidate = requestedModule.getGroup() + ":" + requestedModule.getModule() + ":" + requestedModule.getVersion();
return requestedCandidate.contains(stringNotation);
}
if (requested instanceof ProjectComponentSelector) {
ProjectComponentSelector project = (ProjectComponentSelector) requested;
String requestedCandidate = project.getProjectPath();
return requestedCandidate.contains(stringNotation);
}
return false;
}
Aggregations