use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class DefaultDependenciesToModuleDescriptorConverter method addDependencies.
private void addDependencies(BuildableLocalComponentMetadata metaData, ConfigurationInternal configuration) {
AttributeContainerInternal attributes = configuration.getAttributes();
for (Dependency dependency : configuration.getDependencies()) {
if (dependency instanceof ModuleDependency) {
ModuleDependency moduleDependency = (ModuleDependency) dependency;
metaData.addDependency(dependencyDescriptorFactory.createDependencyDescriptor(configuration.getName(), attributes, moduleDependency));
} else if (dependency instanceof FileCollectionDependency) {
final FileCollectionDependency fileDependency = (FileCollectionDependency) dependency;
metaData.addFiles(configuration.getName(), new DefaultLocalFileDependencyMetadata(fileDependency));
} else {
throw new IllegalArgumentException("Cannot convert dependency " + dependency + " to local component dependency metadata.");
}
}
}
use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class ModuleFactoryDelegateTest method dependency.
@Test
public void dependency() {
final String dependencyNotation = "someNotation";
final ModuleDependency dependencyDummy = context.mock(ModuleDependency.class);
letFactoryStubReturnDependency(dependencyNotation, dependencyDummy);
moduleFactoryDelegate.dependency(dependencyNotation);
assertThat(clientModule.getDependencies(), Matchers.equalTo(WrapUtil.toSet(dependencyDummy)));
}
use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class ModuleFactoryDelegateTest method dependencyWithClosure.
@Test
public void dependencyWithClosure() {
final String dependencyNotation = "someNotation";
final Closure configureClosure = TestUtil.toClosure("{}");
final ModuleDependency dependencyDummy = context.mock(ModuleDependency.class);
letFactoryStubReturnDependency(dependencyNotation, dependencyDummy);
moduleFactoryDelegate.dependency(dependencyNotation, configureClosure);
assertThat(clientModule.getDependencies(), Matchers.equalTo(WrapUtil.toSet(dependencyDummy)));
}
use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class ModuleFactoryDelegateTest method dependencies.
@Test
public void dependencies() {
final String dependencyNotation1 = "someNotation1";
final String dependencyNotation2 = "someNotation2";
final ModuleDependency dependencyDummy1 = context.mock(ModuleDependency.class, "dep1");
final ModuleDependency dependencyDummy2 = context.mock(ModuleDependency.class, "dep2");
letFactoryStubReturnDependency(dependencyNotation1, dependencyDummy1);
letFactoryStubReturnDependency(dependencyNotation2, dependencyDummy2);
moduleFactoryDelegate.dependencies((Object[]) WrapUtil.toArray(dependencyNotation1, dependencyNotation2));
assertThat(clientModule.getDependencies(), Matchers.equalTo(WrapUtil.toSet(dependencyDummy1, dependencyDummy2)));
}
use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class DefaultIvyPublication method from.
public void from(SoftwareComponent component) {
if (this.component != null) {
throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name));
}
this.component = (SoftwareComponentInternal) component;
configurations.maybeCreate("default");
Set<PublishArtifact> seenArtifacts = Sets.newHashSet();
Set<ModuleDependency> seenDependencies = Sets.newHashSet();
for (UsageContext usageContext : getSortedUsageContexts()) {
Usage usage = usageContext.getUsage();
String conf = mapUsage(usage);
configurations.maybeCreate(conf);
configurations.getByName("default").extend(conf);
for (PublishArtifact publishArtifact : usageContext.getArtifacts()) {
if (!seenArtifacts.contains(publishArtifact)) {
seenArtifacts.add(publishArtifact);
artifact(publishArtifact).setConf(conf);
}
}
for (ModuleDependency dependency : usageContext.getDependencies()) {
if (seenDependencies.add(dependency)) {
// TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id.
String confMapping = String.format("%s->%s", conf, dependency.getTargetConfiguration() == null ? Dependency.DEFAULT_CONFIGURATION : dependency.getTargetConfiguration());
if (dependency instanceof ProjectDependency) {
addProjectDependency((ProjectDependency) dependency, confMapping);
} else {
addExternalDependency((ExternalDependency) dependency, confMapping);
}
}
}
}
}
Aggregations