Search in sources :

Example 1 with ModuleVersionSelector

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);
    }
}
Also used : DefaultProjectDependencyMetadata(org.gradle.internal.component.local.model.DefaultProjectDependencyMetadata) DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector)

Example 2 with ModuleVersionSelector

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);
}
Also used : DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector)

Example 3 with ModuleVersionSelector

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);
    }
}
Also used : DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector)

Example 4 with ModuleVersionSelector

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();
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 5 with ModuleVersionSelector

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));
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) Exclude(org.gradle.internal.component.model.Exclude) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) IvyDependencyMetadata(org.gradle.internal.component.external.model.IvyDependencyMetadata) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule) Artifact(org.gradle.internal.component.external.descriptor.Artifact) DependencyArtifactDescriptor(org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) List(java.util.List) Map(java.util.Map)

Aggregations

ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)20 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)9 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)6 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Map (java.util.Map)4 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)4 LinkedHashMap (java.util.LinkedHashMap)3 UnresolvedDependency (org.gradle.api.artifacts.UnresolvedDependency)3 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)3 DefaultUnresolvedDependency (org.gradle.api.internal.artifacts.ivyservice.DefaultUnresolvedDependency)3 Exclude (org.gradle.internal.component.model.Exclude)3 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)2 DslOriginDependencyMetadataWrapper (org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper)2 LocalComponentDependencyMetadata (org.gradle.internal.component.model.LocalComponentDependencyMetadata)2 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)2 DependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)1