Search in sources :

Example 1 with ModuleDependency

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

the class ResolvedConfigurationDependencyGraphVisitor method visitEdges.

public void visitEdges(DependencyGraphNode resolvedConfiguration) {
    for (DependencyGraphEdge dependency : resolvedConfiguration.getIncomingEdges()) {
        if (dependency.getFrom() == root) {
            ModuleDependency moduleDependency = dependency.getModuleDependency();
            builder.addFirstLevelDependency(moduleDependency, resolvedConfiguration);
        }
    }
}
Also used : ModuleDependency(org.gradle.api.artifacts.ModuleDependency) DependencyGraphEdge(org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphEdge)

Example 2 with ModuleDependency

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

the class ClientModuleResolver method addClientModuleDependencies.

private void addClientModuleDependencies(ClientModule clientModule, MutableModuleComponentResolveMetadata clientModuleMetaData) {
    List<DependencyMetadata> dependencies = Lists.newArrayList();
    for (ModuleDependency moduleDependency : clientModule.getDependencies()) {
        DependencyMetadata dependencyMetadata = dependencyDescriptorFactory.createDependencyDescriptor(moduleDependency.getTargetConfiguration(), null, moduleDependency);
        dependencies.add(dependencyMetadata);
    }
    clientModuleMetaData.setDependencies(dependencies);
}
Also used : ModuleDependency(org.gradle.api.artifacts.ModuleDependency) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata)

Example 3 with ModuleDependency

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

the class ModuleFactoryDelegateTest method module.

@Test
public void module() {
    final String clientModuleNotation = "someNotation";
    final Closure configureClosure = TestUtil.toClosure("{}");
    final ClientModule clientModuleDummy = context.mock(ClientModule.class);
    context.checking(new Expectations() {

        {
            allowing(dependencyFactoryStub).createModule(clientModuleNotation, configureClosure);
            will(returnValue(clientModuleDummy));
        }
    });
    moduleFactoryDelegate.module(clientModuleNotation, configureClosure);
    assertThat(this.clientModule.getDependencies(), Matchers.equalTo(WrapUtil.<ModuleDependency>toSet(clientModuleDummy)));
}
Also used : Expectations(org.jmock.Expectations) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) Closure(groovy.lang.Closure) ClientModule(org.gradle.api.artifacts.ClientModule) DefaultClientModule(org.gradle.api.internal.artifacts.dependencies.DefaultClientModule) Test(org.junit.Test)

Example 4 with ModuleDependency

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

the class ExternalModuleDependencyDescriptorFactoryTest method testAddWithNullGroupAndNullVersionShouldHaveEmptyStringModuleRevisionValues.

@Test
public void testAddWithNullGroupAndNullVersionShouldHaveEmptyStringModuleRevisionValues() {
    ModuleDependency dependency = new DefaultExternalModuleDependency(null, "gradle-core", null, TEST_DEP_CONF);
    LocalOriginDependencyMetadata dependencyMetaData = externalModuleDependencyDescriptorFactory.createDependencyDescriptor(componentId, TEST_CONF, null, dependency);
    ModuleComponentSelector selector = (ModuleComponentSelector) dependencyMetaData.getSelector();
    assertThat(selector.getGroup(), equalTo(""));
    assertThat(selector.getModule(), equalTo("gradle-core"));
    assertThat(selector.getVersion(), equalTo(""));
    assertThat(selector.getVersionConstraint().getPreferredVersion(), equalTo(""));
}
Also used : ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) LocalOriginDependencyMetadata(org.gradle.internal.component.model.LocalOriginDependencyMetadata) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) Test(org.junit.Test)

Example 5 with ModuleDependency

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

the class DefaultLocalConfigurationMetadataBuilder method addDependencies.

private void addDependencies(BuildableLocalConfigurationMetadata configurationMetadata, ConfigurationInternal configuration) {
    AttributeContainerInternal attributes = configuration.getAttributes();
    for (Dependency dependency : configuration.getDependencies()) {
        if (dependency instanceof ModuleDependency) {
            ModuleDependency moduleDependency = (ModuleDependency) dependency;
            configurationMetadata.addDependency(dependencyDescriptorFactory.createDependencyDescriptor(configurationMetadata.getComponentId(), configuration.getName(), attributes, moduleDependency));
        } else if (dependency instanceof FileCollectionDependency) {
            final FileCollectionDependency fileDependency = (FileCollectionDependency) dependency;
            configurationMetadata.addFiles(new DefaultLocalFileDependencyMetadata(fileDependency));
        } else {
            throw new IllegalArgumentException("Cannot convert dependency " + dependency + " to local component dependency metadata.");
        }
    }
}
Also used : ModuleDependency(org.gradle.api.artifacts.ModuleDependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) Dependency(org.gradle.api.artifacts.Dependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal)

Aggregations

ModuleDependency (org.gradle.api.artifacts.ModuleDependency)25 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)8 Dependency (org.gradle.api.artifacts.Dependency)6 Test (org.junit.Test)5 Closure (groovy.lang.Closure)3 InvalidUserDataException (org.gradle.api.InvalidUserDataException)3 DependencyConstraint (org.gradle.api.artifacts.DependencyConstraint)3 ExternalModuleDependency (org.gradle.api.artifacts.ExternalModuleDependency)3 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)3 UsageContext (org.gradle.api.internal.component.UsageContext)3 HashMap (java.util.HashMap)2 ExcludeRule (org.gradle.api.artifacts.ExcludeRule)2 ExternalDependency (org.gradle.api.artifacts.ExternalDependency)2 FileCollectionDependency (org.gradle.api.artifacts.FileCollectionDependency)2 MinimalExternalModuleDependency (org.gradle.api.artifacts.MinimalExternalModuleDependency)2 HasConfigurableAttributes (org.gradle.api.attributes.HasConfigurableAttributes)2 Capability (org.gradle.api.capabilities.Capability)2 DefaultExcludeRule (org.gradle.api.internal.artifacts.DefaultExcludeRule)2 MavenDependency (org.gradle.api.publish.maven.MavenDependency)2 DefaultMavenDependency (org.gradle.api.publish.maven.internal.dependencies.DefaultMavenDependency)2