Search in sources :

Example 91 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class PomModuleDescriptorParserTest method testDependenciesWithScope.

@Test
public void testDependenciesWithScope() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-dependencies-with-scope.pom"), false);
    assertNotNull(md);
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test", "1.0"), md.getModuleRevisionId());
    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(3, dds.length);
    assertEquals(ModuleRevisionId.newInstance("odmg", "odmg", "3.0"), dds[0].getDependencyRevisionId());
    assertEquals(new HashSet<>(Collections.singletonList("runtime")), new HashSet<>(Arrays.asList(dds[0].getModuleConfigurations())));
    assertEquals(new HashSet<>(Arrays.asList("compile(*)", "runtime(*)", "master(*)")), new HashSet<>(Arrays.asList(dds[0].getDependencyConfigurations("runtime"))));
    assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[1].getDependencyRevisionId());
    assertEquals(new HashSet<>(Arrays.asList("compile", "runtime")), new HashSet<>(Arrays.asList(dds[1].getModuleConfigurations())));
    assertEquals(new HashSet<>(Arrays.asList("master(*)", "compile(*)")), new HashSet<>(Arrays.asList(dds[1].getDependencyConfigurations("compile"))));
    assertEquals(new HashSet<>(Collections.singletonList("runtime(*)")), new HashSet<>(Arrays.asList(dds[1].getDependencyConfigurations("runtime"))));
    assertEquals(ModuleRevisionId.newInstance("cglib", "cglib", "2.0.2"), dds[2].getDependencyRevisionId());
    assertEquals(new HashSet<>(Arrays.asList("compile", "runtime")), new HashSet<>(Arrays.asList(dds[2].getModuleConfigurations())));
    assertEquals(new HashSet<>(Arrays.asList("master(*)", "compile(*)")), new HashSet<>(Arrays.asList(dds[2].getDependencyConfigurations("compile"))));
    assertEquals(new HashSet<>(Collections.singletonList("runtime(*)")), new HashSet<>(Arrays.asList(dds[2].getDependencyConfigurations("runtime"))));
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 92 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class PomModuleDescriptorParserTest method testParentBomImport.

@Test
public void testParentBomImport() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {

        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource(String.format("depmgt/%s.pom", dd.getDependencyId().getName())), false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("depmgt/child.pom"), false);
    assertNotNull(md);
    assertEquals("1.0", md.getRevision());
    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(1, dds.length);
    assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
}
Also used : ResolveData(org.apache.ivy.core.resolve.ResolveData) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) MockResolver(org.apache.ivy.plugins.resolver.MockResolver) ParseException(java.text.ParseException) IOException(java.io.IOException) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 93 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class PomModuleDescriptorParserTest method testEjbType.

@Test
public void testEjbType() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-ejb-type.pom"), false);
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test-ejb-type", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    DependencyDescriptor[] deps = md.getDependencies();
    assertNotNull(deps);
    assertEquals(1, deps.length);
    DependencyArtifactDescriptor[] artifacts = deps[0].getAllDependencyArtifacts();
    assertNotNull(artifacts);
    assertEquals(1, artifacts.length);
    assertEquals("test", artifacts[0].getName());
    assertEquals("jar", artifacts[0].getExt());
    assertEquals("ejb", artifacts[0].getType());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyArtifactDescriptor(org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 94 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class PomModuleDescriptorParserTest method testDependencyManagementWithScope.

@Test
public void testDependencyManagementWithScope() throws ParseException, IOException {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-dependencyMgt-with-scope.pom"), false);
    assertNotNull(md);
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-depMgt", "1.1"), md.getModuleRevisionId());
    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(1, dds.length);
    assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
    assertEquals("There is no special artifact when there is no classifier", 0, dds[0].getAllDependencyArtifacts().length);
    assertEquals("The number of configurations is incorrect", 1, dds[0].getModuleConfigurations().length);
    assertEquals("The configuration must be test", "test", dds[0].getModuleConfigurations()[0]);
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 95 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class PomModuleDescriptorParserTest method testOverrideGrandparentProperties.

@Test
public void testOverrideGrandparentProperties() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {

        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
            String resource;
            if ("test".equals(dd.getDependencyId().getName())) {
                resource = "test-parent-properties.pom";
            } else {
                resource = "test-version.pom";
            }
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource(resource), false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-override-grandparent-properties.pom"), false);
    assertNotNull(md);
    assertEquals("1.0", md.getRevision());
    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(3, dds.length);
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-version-other", "5.79"), dds[0].getDependencyRevisionId());
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-yet-other", "5.79"), dds[2].getDependencyRevisionId());
}
Also used : ResolveData(org.apache.ivy.core.resolve.ResolveData) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) MockResolver(org.apache.ivy.plugins.resolver.MockResolver) ParseException(java.text.ParseException) IOException(java.io.IOException) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Aggregations

ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)284 Test (org.junit.Test)233 File (java.io.File)143 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)114 ResolveReport (org.apache.ivy.core.report.ResolveReport)94 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)80 JarFile (java.util.jar.JarFile)76 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)76 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)69 IvySettings (org.apache.ivy.core.settings.IvySettings)60 XmlModuleDescriptorParserTest (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest)44 Configuration (org.apache.ivy.core.module.descriptor.Configuration)30 Artifact (org.apache.ivy.core.module.descriptor.Artifact)28 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)27 IOException (java.io.IOException)24 ParseException (java.text.ParseException)23 Ivy (org.apache.ivy.Ivy)23 BufferedReader (java.io.BufferedReader)19 FileReader (java.io.FileReader)19 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)17