use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class ConfigurationBoundExternalDependencyMetadata method withTarget.
@Override
public DependencyMetadata withTarget(ComponentSelector target) {
if (target instanceof ModuleComponentSelector) {
ModuleComponentSelector moduleTarget = (ModuleComponentSelector) target;
ModuleComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(moduleTarget.getModuleIdentifier(), moduleTarget.getVersionConstraint(), moduleTarget.getAttributes(), moduleTarget.getRequestedCapabilities());
if (newSelector.equals(getSelector())) {
return this;
}
return withRequested(newSelector);
} else if (target instanceof ProjectComponentSelector) {
ProjectComponentSelector projectTarget = (ProjectComponentSelector) target;
return new DefaultProjectDependencyMetadata(projectTarget, this);
} else {
throw new IllegalArgumentException("Unexpected selector provided: " + target);
}
}
use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class DefaultIvyModuleResolveMetadata method withDynamicConstraintVersions.
@Override
public IvyModuleResolveMetadata withDynamicConstraintVersions() {
List<IvyDependencyDescriptor> transformed = CollectionUtils.collect(getDependencies(), dependency -> {
ModuleComponentSelector selector = dependency.getSelector();
String dynamicConstraintVersion = dependency.getDynamicConstraintVersion();
ModuleComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(selector.getModuleIdentifier(), dynamicConstraintVersion);
return dependency.withRequested(newSelector);
});
return this.withDependencies(transformed);
}
use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class RealisedIvyModuleResolveMetadataSerializationHelper method readIvyDependency.
private IvyDependencyDescriptor readIvyDependency(Decoder decoder) throws IOException {
ModuleComponentSelector requested = getComponentSelectorSerializer().read(decoder);
SetMultimap<String, String> configMappings = readDependencyConfigurationMapping(decoder);
List<Artifact> artifacts = readDependencyArtifactDescriptors(decoder);
List<Exclude> excludes = readDependencyExcludes(decoder);
String dynamicConstraintVersion = decoder.readString();
boolean changing = decoder.readBoolean();
boolean transitive = decoder.readBoolean();
boolean optional = decoder.readBoolean();
return new IvyDependencyDescriptor(requested, dynamicConstraintVersion, changing, transitive, optional, configMappings, artifacts, excludes);
}
use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class DefaultComponentSelectorConverter method getSelector.
@Override
public ModuleVersionSelector getSelector(ComponentSelector selector) {
if (selector instanceof ModuleComponentSelector) {
return DefaultModuleVersionSelector.newSelector((ModuleComponentSelector) selector);
}
if (selector instanceof ProjectComponentSelector) {
ProjectComponentSelector projectSelector = (ProjectComponentSelector) selector;
ProjectComponentIdentifier projectId = componentIdentifierFactory.createProjectComponentIdentifier(projectSelector);
LocalComponentMetadata projectComponent = localComponentRegistry.getComponent(projectId);
if (projectComponent != null) {
ModuleVersionIdentifier moduleVersionId = projectComponent.getModuleVersionId();
return DefaultModuleVersionSelector.newSelector(moduleVersionId.getModule(), moduleVersionId.getVersion());
}
}
if (selector instanceof LibraryComponentSelector) {
LibraryComponentSelector libraryComponentSelector = (LibraryComponentSelector) selector;
String libraryName = GUtil.elvis(libraryComponentSelector.getLibraryName(), "");
return DefaultModuleVersionSelector.newSelector(DefaultModuleIdentifier.newId(libraryComponentSelector.getProjectPath(), libraryName), "undefined");
}
return UNKNOWN_MODULE_VERSION_SELECTOR;
}
use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.
the class ExternalModuleIvyDependencyDescriptorFactory method createDependencyDescriptor.
@Override
public LocalOriginDependencyMetadata createDependencyDescriptor(ComponentIdentifier componentId, @Nullable String clientConfiguration, @Nullable AttributeContainer clientAttributes, ModuleDependency dependency) {
ExternalModuleDependency externalModuleDependency = (ExternalModuleDependency) dependency;
boolean force = externalModuleDependency.isForce();
boolean changing = externalModuleDependency.isChanging();
boolean transitive = externalModuleDependency.isTransitive();
ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(nullToEmpty(dependency.getGroup()), nullToEmpty(dependency.getName())), ((VersionConstraintInternal) externalModuleDependency.getVersionConstraint()).asImmutable(), dependency.getAttributes(), dependency.getRequestedCapabilities());
List<ExcludeMetadata> excludes = convertExcludeRules(dependency.getExcludeRules());
LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata(componentId, selector, clientConfiguration, clientAttributes, dependency.getAttributes(), dependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), excludes, force, changing, transitive, false, dependency.isEndorsingStrictVersions(), dependency.getReason());
return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency);
}
Aggregations