use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testExtendsDescription.
@Test
public void testExtendsDescription() throws Exception {
// descriptor specifies that only parent description should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-extends-description.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 merged.
assertEquals("Parent module description.", md.getDescription());
// verify that the parent configurations were ignored.
final Configuration[] expectedConfs = { new Configuration("default") };
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(Collections.singletonList("default"), 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 testImportConfigurations1.
@Test
public void testImportConfigurations1() throws Exception {
// import configurations
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-configurations-import1.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 testDefaultConf2.
@Test
public void testDefaultConf2() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-defaultconf2.xml"), true);
assertNotNull(md);
DependencyDescriptor[] dependencies = md.getDependencies();
assertNotNull(dependencies);
assertEquals(2, dependencies.length);
// no conf def => defaults to defaultConf: *->default
DependencyDescriptor dd = getDependency(dependencies, "mymodule1");
assertNotNull(dd);
assertEquals("myorg", dd.getDependencyId().getOrganisation());
assertEquals("1.0", dd.getDependencyRevisionId().getRevision());
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("default"), Arrays.asList(dd.getDependencyConfigurations("default")));
assertEquals(Collections.singletonList("default"), Arrays.asList(dd.getDependencyConfigurations("test")));
// confs def: test: should not use default conf for the right side (use of
// defaultconfmapping is required for that) => test->test
dd = getDependency(dependencies, "mymodule2");
assertNotNull(dd);
assertEquals("myorg", dd.getDependencyId().getOrganisation());
assertEquals("2.0", dd.getDependencyRevisionId().getRevision());
assertEquals(Collections.singletonList("test"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("test"), Arrays.asList(dd.getDependencyConfigurations("test")));
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testDefaultConfMappingWithSelectors.
@Test
public void testDefaultConfMappingWithSelectors() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-defaultconfmapping-withselectors.xml"), true);
assertNotNull(md);
// has 3 dependencies
DependencyDescriptor[] dependencies = md.getDependencies();
assertNotNull(dependencies);
assertEquals(3, dependencies.length);
// confs dep1: *->default1,default3
DependencyDescriptor dd = getDependency(dependencies, "mymodule1");
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Arrays.asList("default1", "default3"), Arrays.asList(dd.getDependencyConfigurations("default")));
// confs dep2: test->default2,default3
dd = getDependency(dependencies, "mymodule2");
assertEquals(Collections.singletonList("test"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Arrays.asList("default2", "default3"), Arrays.asList(dd.getDependencyConfigurations("test")));
// confs dep3: *->default4
dd = getDependency(dependencies, "mymodule3");
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("default4"), Arrays.asList(dd.getDependencyConfigurations("bla")));
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorParserTest method testDefaultConfMapping.
@Test
public void testDefaultConfMapping() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-defaultconfmapping.xml"), true);
assertNotNull(md);
DependencyDescriptor[] dependencies = md.getDependencies();
assertNotNull(dependencies);
assertEquals(2, dependencies.length);
// no conf def => defaults to defaultConf: *->default
DependencyDescriptor dd = getDependency(dependencies, "mymodule1");
assertNotNull(dd);
assertEquals("myorg", dd.getDependencyId().getOrganisation());
assertEquals("1.0", dd.getDependencyRevisionId().getRevision());
assertEquals(Collections.singletonList("*"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("default"), Arrays.asList(dd.getDependencyConfigurations("default")));
assertEquals(Collections.singletonList("default"), Arrays.asList(dd.getDependencyConfigurations("test")));
// confs def: test: should use default conf mapping for the right side => test->default
dd = getDependency(dependencies, "mymodule2");
assertNotNull(dd);
assertEquals("myorg", dd.getDependencyId().getOrganisation());
assertEquals("2.0", dd.getDependencyRevisionId().getRevision());
assertEquals(Collections.singletonList("test"), Arrays.asList(dd.getModuleConfigurations()));
assertEquals(Collections.singletonList("default"), Arrays.asList(dd.getDependencyConfigurations("test")));
}
Aggregations