use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.
the class DefaultDependencyMetadata method withTarget.
@Override
public DependencyMetadata withTarget(ComponentSelector target) {
if (target instanceof ModuleComponentSelector) {
ModuleComponentSelector moduleTarget = (ModuleComponentSelector) target;
ModuleVersionSelector requestedVersion = DefaultModuleVersionSelector.newSelector(moduleTarget.getGroup(), moduleTarget.getModule(), moduleTarget.getVersion());
if (requestedVersion.equals(requested)) {
return this;
}
return withRequested(requestedVersion);
} 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.ModuleVersionSelector in project gradle by gradle.
the class LocalComponentDependencyMetadata method withRequestedVersion.
@Override
public LocalOriginDependencyMetadata withRequestedVersion(String requestedVersion) {
if (requestedVersion.equals(requested.getVersion())) {
return this;
}
ModuleVersionSelector newRequested = DefaultModuleVersionSelector.newSelector(requested.getGroup(), requested.getName(), requestedVersion);
ComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(newRequested);
return copyWithTarget(newSelector, newRequested);
}
use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.
the class LocalComponentDependencyMetadata method withTarget.
@Override
public LocalOriginDependencyMetadata withTarget(ComponentSelector target) {
if (target instanceof ModuleComponentSelector) {
ModuleComponentSelector moduleTarget = (ModuleComponentSelector) target;
ModuleVersionSelector requestedVersion = DefaultModuleVersionSelector.newSelector(moduleTarget.getGroup(), moduleTarget.getModule(), moduleTarget.getVersion());
if (selector.equals(target) && requested.equals(requestedVersion)) {
return this;
}
return copyWithTarget(moduleTarget, requestedVersion);
} else if (target instanceof ProjectComponentSelector) {
if (target.equals(selector)) {
return this;
}
return copyWithTarget(target, requested);
} else {
throw new AssertionError("Invalid component selector type for substitution: " + target);
}
}
use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.
the class IvyXmlModuleDescriptorWriter method printDependency.
protected void printDependency(IvyModulePublishMetadata metadata, LocalOriginDependencyMetadata dep, SimpleXmlWriter writer) throws IOException {
writer.startElement("dependency");
ModuleVersionSelector requested = dep.getRequested();
writer.attribute("org", requested.getGroup());
writer.attribute("name", requested.getName());
writer.attribute("rev", requested.getVersion());
if (dep.getDynamicConstraintVersion() != null && !dep.getDynamicConstraintVersion().equals(requested.getVersion())) {
writer.attribute("revConstraint", dep.getDynamicConstraintVersion());
}
if (dep.isForce()) {
writer.attribute("force", "true");
}
if (dep.isChanging()) {
writer.attribute("changing", "true");
}
if (!dep.isTransitive()) {
writer.attribute("transitive", "false");
}
writer.attribute("conf", getConfMapping(dep));
for (IvyArtifactName dependencyArtifact : dep.getArtifacts()) {
printDependencyArtifact(writer, dependencyArtifact, dep.getModuleConfiguration());
}
printDependencyExcludeRules(metadata, writer, dep.getExcludes());
writer.endElement();
}
use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.
the class IvyModuleDescriptorConverter method addDependency.
private void addDependency(List<IvyDependencyMetadata> result, DependencyDescriptor dependencyDescriptor) {
ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId();
ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(revisionId.getOrganisation(), revisionId.getName(), revisionId.getRevision());
ListMultimap<String, String> configMappings = ArrayListMultimap.create();
for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) {
configMappings.putAll(entry.getKey(), entry.getValue());
}
List<Artifact> artifacts = Lists.newArrayList();
for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) {
IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER));
artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations())));
}
List<Exclude> excludes = Lists.newArrayList();
for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) {
excludes.add(forIvyExclude(excludeRule));
}
result.add(new IvyDependencyMetadata(requested, dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(), false, dependencyDescriptor.isChanging(), dependencyDescriptor.isTransitive(), configMappings, artifacts, excludes));
}
Aggregations