Search in sources :

Example 11 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class ResolvedConfigurationDependencyGraphVisitor method attachFailures.

private void attachFailures(ResolvedConfigurationBuilder result) {
    for (Map.Entry<ModuleVersionSelector, BrokenDependency> entry : failuresByRevisionId.entrySet()) {
        Collection<List<ComponentIdentifier>> paths = DependencyGraphPathResolver.calculatePaths(entry.getValue().requiredBy, root);
        result.addUnresolvedDependency(new DefaultUnresolvedDependency(entry.getKey(), entry.getValue().failure.withIncomingPaths(paths)));
    }
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) DefaultUnresolvedDependency(org.gradle.api.internal.artifacts.ivyservice.DefaultUnresolvedDependency) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 12 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class ProjectIvyDependencyDescriptorFactory method createDependencyDescriptor.

public DslOriginDependencyMetadata createDependencyDescriptor(String clientConfiguration, AttributeContainer clientAttributes, ModuleDependency dependency) {
    ProjectDependencyInternal projectDependency = (ProjectDependencyInternal) dependency;
    projectDependency.beforeResolved();
    Module module = getProjectModule(dependency);
    ModuleVersionSelector requested = new DefaultModuleVersionSelector(module.getGroup(), module.getName(), module.getVersion());
    ComponentSelector selector = DefaultProjectComponentSelector.newSelector(projectDependency.getDependencyProject());
    List<Exclude> excludes = convertExcludeRules(clientConfiguration, dependency.getExcludeRules());
    LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata(selector, requested, clientConfiguration, clientAttributes, projectDependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), excludes, false, false, dependency.isTransitive());
    return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency);
}
Also used : ProjectDependencyInternal(org.gradle.api.internal.artifacts.dependencies.ProjectDependencyInternal) DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) Exclude(org.gradle.internal.component.model.Exclude) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) DslOriginDependencyMetadataWrapper(org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper) Module(org.gradle.api.internal.artifacts.Module) LocalComponentDependencyMetadata(org.gradle.internal.component.model.LocalComponentDependencyMetadata)

Example 13 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class RepositoryChainDependencyToComponentIdResolver method resolve.

public void resolve(DependencyMetadata dependency, BuildableComponentIdResolveResult result) {
    ModuleVersionSelector requested = dependency.getRequested();
    if (versionSelectorScheme.parseSelector(requested.getVersion()).isDynamic()) {
        dynamicRevisionResolver.resolve(dependency, result);
    } else {
        DefaultModuleComponentIdentifier id = new DefaultModuleComponentIdentifier(requested.getGroup(), requested.getName(), requested.getVersion());
        ModuleVersionIdentifier mvId = moduleIdentifierFactory.moduleWithVersion(requested.getGroup(), requested.getName(), requested.getVersion());
        result.resolved(id, mvId);
    }
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)

Example 14 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class GradlePomModuleDescriptorBuilder method addDependency.

public void addDependency(PomDependencyData dep) {
    String scopeString = dep.getScope();
    if (scopeString == null || scopeString.length() == 0) {
        scopeString = getDefaultScope(dep);
    }
    MavenScope scope;
    if (SCOPES.containsKey(scopeString)) {
        scope = SCOPES.get(scopeString);
    } else {
        // unknown scope, defaulting to 'compile'
        scope = MavenScope.Compile;
    }
    String version = determineVersion(dep);
    String mappedVersion = convertVersionFromMavenSyntax(version);
    ModuleVersionSelector selector = DefaultModuleVersionSelector.newSelector(dep.getGroupId(), dep.getArtifactId(), mappedVersion);
    // Example: http://repo2.maven.org/maven2/net/jini/jsk-platform/2.1/jsk-platform-2.1.pom
    if (selector.getGroup().equals(descriptor.getComponentIdentifier().getGroup()) && selector.getName().equals(descriptor.getComponentIdentifier().getModule())) {
        return;
    }
    boolean optional = dep.isOptional();
    List<Artifact> artifacts = Lists.newArrayList();
    boolean hasClassifier = dep.getClassifier() != null && dep.getClassifier().length() > 0;
    boolean hasNonJarType = dep.getType() != null && !"jar".equals(dep.getType());
    if (hasClassifier || hasNonJarType) {
        String type = "jar";
        if (dep.getType() != null) {
            type = dep.getType();
        }
        String ext = determineExtension(type);
        String classifier = hasClassifier ? dep.getClassifier() : getClassifierForType(type);
        // here we have to assume a type and ext for the artifact, so this is a limitation
        // compared to how m2 behave with classifiers
        String optionalizedScope = optional ? "optional" : scope.toString().toLowerCase();
        IvyArtifactName artifactName = new DefaultIvyArtifactName(selector.getName(), type, ext, classifier);
        artifacts.add(new Artifact(artifactName, Collections.singleton(optionalizedScope)));
    }
    // experimentation shows the following, excluded modules are
    // inherited from parent POMs if either of the following is true:
    // the <exclusions> element is missing or the <exclusions> element
    // is present, but empty.
    List<Exclude> excludes = Lists.newArrayList();
    List<ModuleIdentifier> excluded = dep.getExcludedModules();
    if (excluded.isEmpty()) {
        excluded = getDependencyMgtExclusions(dep);
    }
    for (ModuleIdentifier excludedModule : excluded) {
        DefaultExclude rule = new DefaultExclude(moduleIdentifierFactory.module(excludedModule.getGroup(), excludedModule.getName()), WILDCARD, PatternMatchers.EXACT);
        excludes.add(rule);
    }
    dependencies.add(new MavenDependencyMetadata(scope, optional, selector, 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) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) Artifact(org.gradle.internal.component.external.descriptor.Artifact) MavenDependencyMetadata(org.gradle.internal.component.external.model.MavenDependencyMetadata) MavenScope(org.gradle.internal.component.external.descriptor.MavenScope) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 15 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class DefaultLibraryLocalComponentMetadata method moduleDependencyMetadata.

private LocalOriginDependencyMetadata moduleDependencyMetadata(ModuleDependencySpec moduleDependency, String usageConfigurationName) {
    ModuleVersionSelector requested = moduleVersionSelectorFrom(moduleDependency);
    ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(requested);
    // Instead, we should be creating an API configuration for each resolved module
    return dependencyMetadataFor(selector, requested, usageConfigurationName, CONFIGURATION_COMPILE);
}
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)

Aggregations

ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)18 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)9 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)5 Exclude (org.gradle.internal.component.model.Exclude)4 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)3 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)3 LinkedHashMap (java.util.LinkedHashMap)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)2 DefaultUnresolvedDependency (org.gradle.api.internal.artifacts.ivyservice.DefaultUnresolvedDependency)2 Artifact (org.gradle.internal.component.external.descriptor.Artifact)2 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)2 DslOriginDependencyMetadataWrapper (org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper)2 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)2 LocalComponentDependencyMetadata (org.gradle.internal.component.model.LocalComponentDependencyMetadata)2 ImmutableSet (com.google.common.collect.ImmutableSet)1