Search in sources :

Example 66 with ModuleDescriptor

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

the class ResolveTest method testEvictWithConfInMultiConf2.

@Test
public void testEvictWithConfInMultiConf2() throws Exception {
    // same as preceding one but the conflict appears in a root conf and not in another
    // which should keep the evicted
    // bug 105 - test #4
    // mod6.1 r1.3 conf A depends on
    // mod5.2 r1.0 which depends on mod5.1 r4.0 conf B
    // 
    // mod6.1 r1.3 conf B depends on
    // mod5.2 r1.0 which depends on mod5.1 r4.0 conf B
    // mod5.1 r4.2 conf A
    // 
    // mod5.1 r4.2 conf B depends on mod1.2 r2.0
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod6.1/ivy-1.3.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "1.3");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.2", "art51A", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.2", "art51B", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org5", "mod5.1", "4.0")).exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org5", "mod5.2", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.2", "1.0", "mod5.2", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
    // 4.2 artifacts should be present in conf B only
    ConfigurationResolveReport crr = report.getConfigurationReport("A");
    assertNotNull(crr);
    assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).length);
    crr = report.getConfigurationReport("B");
    assertNotNull(crr);
    assertEquals(2, crr.getDownloadReports(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).length);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 67 with ModuleDescriptor

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

the class ResolveTest method testResolveForceWithDynamicRevisionsAndSeveralConfs2.

@Test
public void testResolveForceWithDynamicRevisionsAndSeveralConfs2() throws Exception {
    // mod4.1 v 4.7 (conf compile, test extends compile) depends on
    // - mod1.2 v 1+ and forces it in conf compile
    // - mod3.1 v 1.3 in conf test->runtime
    // which defines confs compile, runtime extends compile
    // which depends on mod1.2 v 2+ in conf compile->default
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod4.1/ivy-4.7.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.7");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org3", "mod3.1", "1.3")).exists());
    assertTrue(getArchiveFileInCache("org3", "mod3.1", "1.3", "mod3.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "1.1")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "1.1", "mod1.2", "jar", "jar").exists());
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 68 with ModuleDescriptor

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

the class ResolveTest method testResolveExcludesModuleWide.

@Test
public void testResolveExcludesModuleWide() throws Exception {
    // mod2.6 depends on mod2.1 and excludes mod1.1 module wide
    // mod2.1 depends on mod1.1 which depends on mod1.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.6/ivys/ivy-0.11.xml"), getResolveOptions(new String[] { "*" }));
    ModuleDescriptor md = report.getModuleDescriptor();
    assertEquals(ModuleRevisionId.newInstance("org2", "mod2.6", "0.11"), md.getModuleRevisionId());
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 69 with ModuleDescriptor

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

the class ResolveTest method testResolveMaven2ClassifiersWithoutPOM.

/**
 * Test case for IVY-1041.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1041">IVY-1041</a>
 */
@Test
public void testResolveMaven2ClassifiersWithoutPOM() throws Exception {
    // test-classifier depends on test-classified with classifier asl
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/m2/org/apache/test-classifier/2.0/test-classifier-2.0.pom"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test-classifier", "2.0");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test-classified", "2.0")).exists());
    Map<String, String> cmap = new HashMap<>();
    cmap.put("classifier", "asl");
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-classified", /* branch */
    null, "2.0", "test-classified", "jar", "jar", cmap).exists());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) HashMap(java.util.HashMap) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 70 with ModuleDescriptor

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

the class ResolveTest method testIVY1159_orderIsModBModAReplaceForced.

/**
 * Test case for IVY-1159.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1159">IVY-1159</a>
 */
@Test
public void testIVY1159_orderIsModBModAReplaceForced() throws Exception {
    testIVY1159("ivy-depsorder_modB_then_modA.xml", true);
    File deliveredIvyFile = new File("build/test/deliver/ivy-1.xml");
    assertTrue(deliveredIvyFile.exists());
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings(), deliveredIvyFile.toURI().toURL(), false);
    DependencyDescriptor[] dds = md.getDependencies();
    assertEquals(2, dds.length);
    assertEquals(ModuleRevisionId.newInstance("myorg", "modB", "1"), dds[0].getDependencyRevisionId());
    assertEquals(ModuleRevisionId.newInstance("myorg", "modA", "1"), dds[1].getDependencyRevisionId());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) JarFile(java.util.jar.JarFile) File(java.io.File) 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