Search in sources :

Example 1 with ResolvedDependency

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

the class DefaultLenientConfiguration method getAllModuleDependencies.

public Set<ResolvedDependency> getAllModuleDependencies() {
    Set<ResolvedDependency> resolvedElements = new LinkedHashSet<ResolvedDependency>();
    Deque<ResolvedDependency> workQueue = new LinkedList<ResolvedDependency>();
    workQueue.addAll(loadTransientGraphResults(getSelectedArtifacts()).getRootNode().getPublicView().getChildren());
    while (!workQueue.isEmpty()) {
        ResolvedDependency item = workQueue.removeFirst();
        if (resolvedElements.add(item)) {
            final Set<ResolvedDependency> children = item.getChildren();
            if (children != null) {
                workQueue.addAll(children);
            }
        }
    }
    return resolvedElements;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ResolvedDependency(org.gradle.api.artifacts.ResolvedDependency) LinkedList(java.util.LinkedList)

Example 2 with ResolvedDependency

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

the class DefaultResolvedDependency method getAllArtifacts.

public Set<ResolvedArtifact> getAllArtifacts(ResolvedDependency parent) {
    if (allArtifactsCache.get(parent) == null) {
        Set<ResolvedArtifact> allArtifacts = new LinkedHashSet<ResolvedArtifact>();
        allArtifacts.addAll(getArtifacts(parent));
        for (ResolvedDependency childResolvedDependency : getChildren()) {
            for (ResolvedDependency childParent : childResolvedDependency.getParents()) {
                allArtifacts.addAll(childResolvedDependency.getAllArtifacts(childParent));
            }
        }
        allArtifactsCache.put(parent, allArtifacts);
    }
    return allArtifactsCache.get(parent);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) ResolvedDependency(org.gradle.api.artifacts.ResolvedDependency)

Example 3 with ResolvedDependency

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

the class DefaultResolvedDependencyTest method createResolvedArtifact.

public static DefaultResolvedArtifact createResolvedArtifact(final Mockery context, final String name, final String type, final String extension, final File file) {
    final IvyArtifactName artifactStub = context.mock(IvyArtifactName.class, "artifact" + name);
    final ImmutableAttributesFactory factory = context.mock(ImmutableAttributesFactory.class);
    final BuildOperationExecutor buildOperationExecutor = context.mock(BuildOperationExecutor.class);
    context.checking(new Expectations() {

        {
            allowing(factory).builder(ImmutableAttributes.EMPTY);
            allowing(artifactStub).getName();
            will(returnValue(name));
            allowing(artifactStub).getType();
            will(returnValue(type));
            allowing(artifactStub).getExtension();
            will(returnValue(extension));
            allowing(artifactStub).getClassifier();
            will(returnValue(null));
        }
    });
    final Factory artifactSource = context.mock(Factory.class);
    context.checking(new Expectations() {

        {
            allowing(artifactSource).create();
            will(returnValue(file));
        }
    });
    final ResolvedDependency resolvedDependency = context.mock(ResolvedDependency.class);
    final ResolvedModuleVersion version = context.mock(ResolvedModuleVersion.class);
    context.checking(new Expectations() {

        {
            allowing(resolvedDependency).getModule();
            will(returnValue(version));
            allowing(version).getId();
            will(returnValue(new DefaultModuleVersionIdentifier("group", name, "1.2")));
        }
    });
    return new DefaultResolvedArtifact(resolvedDependency.getModule().getId(), artifactStub, context.mock(ComponentArtifactIdentifier.class), context.mock(TaskDependency.class), artifactSource);
}
Also used : Expectations(org.jmock.Expectations) TaskDependency(org.gradle.api.tasks.TaskDependency) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ResolvedModuleVersion(org.gradle.api.artifacts.ResolvedModuleVersion) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ResolvedDependency(org.gradle.api.artifacts.ResolvedDependency) ImmutableAttributesFactory(org.gradle.api.internal.attributes.ImmutableAttributesFactory) Factory(org.gradle.internal.Factory) ImmutableAttributesFactory(org.gradle.api.internal.attributes.ImmutableAttributesFactory) BuildOperationExecutor(org.gradle.internal.progress.BuildOperationExecutor)

Example 4 with ResolvedDependency

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

the class DefaultResolvedDependency method getAllModuleArtifacts.

public Set<ResolvedArtifact> getAllModuleArtifacts() {
    if (allModuleArtifactsCache == null) {
        Set<ResolvedArtifact> allArtifacts = new LinkedHashSet<ResolvedArtifact>();
        allArtifacts.addAll(getModuleArtifacts());
        for (ResolvedDependency childResolvedDependency : getChildren()) {
            allArtifacts.addAll(childResolvedDependency.getAllModuleArtifacts());
        }
        allModuleArtifactsCache = allArtifacts;
    }
    return allModuleArtifactsCache;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) ResolvedDependency(org.gradle.api.artifacts.ResolvedDependency)

Aggregations

ResolvedDependency (org.gradle.api.artifacts.ResolvedDependency)4 LinkedHashSet (java.util.LinkedHashSet)3 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)2 LinkedList (java.util.LinkedList)1 ResolvedModuleVersion (org.gradle.api.artifacts.ResolvedModuleVersion)1 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)1 ImmutableAttributesFactory (org.gradle.api.internal.attributes.ImmutableAttributesFactory)1 TaskDependency (org.gradle.api.tasks.TaskDependency)1 Factory (org.gradle.internal.Factory)1 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)1 BuildOperationExecutor (org.gradle.internal.progress.BuildOperationExecutor)1 Expectations (org.jmock.Expectations)1