Search in sources :

Example 11 with ComponentSelector

use of org.gradle.api.artifacts.component.ComponentSelector in project gradle by gradle.

the class IdeaDependenciesProvider method getDependencies.

private Set<Dependency> getDependencies(IdeaModule ideaModule) {
    Set<Dependency> dependencies = Sets.newLinkedHashSet();
    Map<ComponentSelector, UnresolvedDependencyResult> unresolvedDependencies = Maps.newLinkedHashMap();
    for (GeneratedIdeaScope scope : GeneratedIdeaScope.values()) {
        IdeaDependenciesVisitor visitor = visitDependencies(ideaModule, scope);
        dependencies.addAll(visitor.getDependencies());
        unresolvedDependencies.putAll(visitor.getUnresolvedDependencies());
    }
    optimizer.optimizeDeps(dependencies);
    new UnresolvedIdeDependencyHandler().log(unresolvedDependencies.values());
    return dependencies;
}
Also used : UnresolvedDependencyResult(org.gradle.api.artifacts.result.UnresolvedDependencyResult) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) UnresolvedIdeDependencyHandler(org.gradle.plugins.ide.internal.resolver.UnresolvedIdeDependencyHandler) Dependency(org.gradle.plugins.ide.idea.model.Dependency)

Example 12 with ComponentSelector

use of org.gradle.api.artifacts.component.ComponentSelector in project gradle by gradle.

the class DefaultLibraryLocalComponentMetadata method projectDependencyMetadata.

// TODO: projectDependency should be transformed based on defaultProject (and other context) elsewhere.
private LocalOriginDependencyMetadata projectDependencyMetadata(ProjectDependencySpec projectDependency, String defaultProject, String usageConfigurationName) {
    String projectPath = projectDependency.getProjectPath();
    if (isNullOrEmpty(projectPath)) {
        projectPath = defaultProject;
    }
    String libraryName = projectDependency.getLibraryName();
    ComponentSelector selector = new DefaultLibraryComponentSelector(projectPath, libraryName);
    return dependencyMetadataFor(selector, usageConfigurationName, usageConfigurationName);
}
Also used : ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultLibraryComponentSelector(org.gradle.internal.component.local.model.DefaultLibraryComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) DefaultLibraryComponentSelector(org.gradle.internal.component.local.model.DefaultLibraryComponentSelector)

Example 13 with ComponentSelector

use of org.gradle.api.artifacts.component.ComponentSelector 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 14 with ComponentSelector

use of org.gradle.api.artifacts.component.ComponentSelector in project gradle by gradle.

the class DependencyResultSerializer method read.

public DependencyResult read(Decoder decoder, Map<Long, ComponentSelector> selectors, Map<ComponentSelector, ModuleVersionResolveException> failures) throws IOException {
    Long selectorId = decoder.readSmallLong();
    ComponentSelector requested = selectors.get(selectorId);
    byte resultByte = decoder.readByte();
    if (resultByte == SUCCESSFUL) {
        Long selectedId = decoder.readSmallLong();
        return new DefaultDependencyResult(requested, selectedId, null, null);
    } else if (resultByte == FAILED) {
        ComponentSelectionReason reason = componentSelectionReasonSerializer.read(decoder);
        ModuleVersionResolveException failure = failures.get(requested);
        return new DefaultDependencyResult(requested, null, reason, failure);
    } else {
        throw new IllegalArgumentException("Unknown result type: " + resultByte);
    }
}
Also used : ComponentSelectionReason(org.gradle.api.artifacts.result.ComponentSelectionReason) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException)

Example 15 with ComponentSelector

use of org.gradle.api.artifacts.component.ComponentSelector in project gradle by gradle.

the class CompositeBuildDependencySubstitutions method execute.

@Override
public void execute(DependencySubstitution sub) {
    DependencySubstitutionInternal dependencySubstitution = (DependencySubstitutionInternal) sub;
    // Use the result of previous rules as the input for dependency substitution
    ComponentSelector requested = dependencySubstitution.getTarget();
    if (requested instanceof ModuleComponentSelector) {
        ModuleComponentSelector selector = (ModuleComponentSelector) requested;
        ProjectComponentIdentifier replacement = getReplacementFor(selector);
        if (replacement != null) {
            dependencySubstitution.useTarget(DefaultProjectComponentSelector.newSelector(replacement), VersionSelectionReasons.COMPOSITE_BUILD);
        }
    }
}
Also used : ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DependencySubstitutionInternal(org.gradle.api.internal.artifacts.DependencySubstitutionInternal) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Aggregations

ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)21 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)9 UnresolvedDependencyResult (org.gradle.api.artifacts.result.UnresolvedDependencyResult)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)4 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)4 File (java.io.File)3 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)3 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)3 ResolvedDependencyResult (org.gradle.api.artifacts.result.ResolvedDependencyResult)3 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)3 JarDependency (com.android.builder.dependency.JarDependency)2 LibraryDependency (com.android.builder.dependency.LibraryDependency)2 MavenCoordinates (com.android.builder.model.MavenCoordinates)2 ImmutableList (com.google.common.collect.ImmutableList)2 HashSet (java.util.HashSet)2 UnresolvedDependency (org.gradle.api.artifacts.UnresolvedDependency)2 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)2 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)2