use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testImportConfigurations5.
@Test
public void testImportConfigurations5() throws Exception {
// import configurations
settings.setVariable("base.dir", new File(".").getAbsolutePath());
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-configurations-import5.xml"), true);
assertNotNull(md);
// should have imported configurations
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(new Configuration("conf1", PUBLIC, "", new String[0], true, null), new Configuration("conf2", PRIVATE, "", new String[0], true, null)), Arrays.asList(md.getConfigurations()));
DependencyDescriptor[] dependencies = md.getDependencies();
assertNotNull(dependencies);
assertEquals(2, dependencies.length);
// no conf def => defaults to defaultConf: *->*
DependencyDescriptor dd = getDependency(dependencies, "mymodule1");
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getDependencyConfigurations("conf1")));
// confs def: conf1->*
dd = getDependency(dependencies, "mymodule2");
assertEquals(Collections.singletonList("conf1"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getDependencyConfigurations("conf1")));
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testExtendsAll.
@Test
public void testExtendsAll() throws Exception {
Message.setDefaultLogger(new DefaultMessageLogger(99));
// default extends type is 'all' when no extendsType attribute is specified.
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-extends-all.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals("myrev", md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was merged.
assertEquals("Parent module description.", md.getDescription());
// verify that the parent and child configurations were merged together.
final Configuration[] expectedConfs = { new Configuration("default"), new Configuration("conf1"), new Configuration("conf2") };
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent and child dependencies were merged together.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(2, deps.length);
assertEquals(Collections.singletonList("default"), Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule1", dep.getModuleId().getName());
assertEquals("1.0", dep.getRevision());
assertEquals(Arrays.asList("conf1", "conf2"), Arrays.asList(deps[1].getModuleConfigurations()));
dep = deps[1].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testExtendsConfigurations.
@Test
public void testExtendsConfigurations() throws Exception {
// descriptor specifies that only parent configurations should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-extends-configurations.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was ignored.
assertEquals("", md.getDescription());
// verify that the parent and child configurations were merged together.
final Configuration[] expectedConfs = { new Configuration("default"), new Configuration("conf1"), new Configuration("conf2") };
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent dependencies were ignored.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(1, deps.length);
assertEquals(Arrays.asList("conf1", "conf2"), Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testImportConfigurationsWithWildcardAndMappingOverride.
@Test
public void testImportConfigurationsWithWildcardAndMappingOverride() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-configextendsothers3.xml"), true);
assertNotNull(md);
// has 2 dependencies
DependencyDescriptor[] dependencies = md.getDependencies();
assertNotNull(dependencies);
assertEquals(2, dependencies.length);
// confs dep1: all-public->all-public (mappingoverride = true)
DependencyDescriptor dd = getDependency(dependencies, "mymodule1");
assertEquals(Collections.singletonList("all-public"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("all-public"), Arrays.asList(dd.getDependencyConfigurations("all-public")));
// confs dep2: extra->extra;all-public->all-public (mappingoverride = true)
dd = getDependency(dependencies, "mymodule2");
assertEquals(Arrays.asList("extra", "all-public"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("extra"), Arrays.asList(dd.getDependencyConfigurations("extra")));
assertEquals(Collections.singletonList("all-public"), Arrays.asList(dd.getDependencyConfigurations("all-public")));
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testImportConfigurationsWithMappingOverride.
@Test
public void testImportConfigurationsWithMappingOverride() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-configurations-import4.xml"), true);
assertNotNull(md);
// has 2 dependencies
DependencyDescriptor[] dependencies = md.getDependencies();
assertNotNull(dependencies);
assertEquals(2, dependencies.length);
// confs dep1: conf1->A;conf2->B (mappingoverride = true)
DependencyDescriptor dd = getDependency(dependencies, "mymodule1");
assertEquals(Arrays.asList("conf1", "conf2"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("A"), Arrays.asList(dd.getDependencyConfigurations("conf1")));
assertEquals(Collections.singletonList("B"), Arrays.asList(dd.getDependencyConfigurations("conf2")));
// confs dep2: conf2->B
dd = getDependency(dependencies, "mymodule2");
assertEquals(Collections.singletonList("conf2"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("B"), Arrays.asList(dd.getDependencyConfigurations("conf2")));
}
Aggregations