Search in sources :

Example 66 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport 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 67 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport 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 68 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport in project ant-ivy by apache.

the class ResolveTest method testDependenciesOrder.

@Test
public void testDependenciesOrder() throws Exception {
    ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-225.xml"), getResolveOptions(new String[] { "default" }));
    List<ModuleRevisionId> revisions = new ArrayList<>(report.getConfigurationReport("default").getModuleRevisionIds());
    assertTrue("number of revisions is not correct", revisions.size() >= 3);
    int mod12Index = revisions.indexOf(ModuleRevisionId.newInstance("org1", "mod1.2", "1.1"));
    int mod32Index = revisions.indexOf(ModuleRevisionId.newInstance("org3", "mod3.2", "1.4"));
    int mod51Index = revisions.indexOf(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2"));
    // verify the order of the modules in the ivy file
    assertTrue("[ org1 | mod1.2 | 1.1 ] was not found", mod12Index > -1);
    assertTrue("[ org1 | mod1.2 | 1.1 ] must come before [ org3 | mod3.2 | 1.4 ]", mod12Index < mod32Index);
    assertTrue("[ org3 | mod3.2 | 1.4 ] must come before [ org5 | mod5.1 | 4.2 ]", mod32Index < mod51Index);
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ArrayList(java.util.ArrayList) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) Test(org.junit.Test)

Example 69 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport in project ant-ivy by apache.

the class ResolveTest method testVersionRange1.

@Test
public void testVersionRange1() throws Exception {
    // mod 1.4 depends on mod1.2 [1.0,2.0[
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] { "default" }));
    assertFalse(report.hasError());
    // dependencies
    ModuleRevisionId depId = ModuleRevisionId.newInstance("org1", "mod1.2", "1.1");
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(1, crr.getDownloadReports(depId).length);
    assertTrue(getIvyFileInCache(depId).exists());
}
Also used : 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 70 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport in project ant-ivy by apache.

the class ResolveTest method testDynamicFromCache.

@Test
public void testDynamicFromCache() throws Exception {
    // mod1.4;1.0.2 depends on mod1.2;[1.0,2.0[
    Ivy ivy = ivyTestCache();
    ivy.getSettings().setVariable("ivy.cache.ttl.default", "10s", true);
    // set up repository
    FileUtil.forceDelete(new File("build/testCache2"));
    FileUtil.copy(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), new File("build/testCache2/mod1.2-1.5.jar"), null);
    // we first do a simple resolve so that module is in cache
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), report.getConfigurationReport("default").getModuleRevisionIds());
    // now we clean the repository to simulate repo not available (network pb for instance)
    FileUtil.forceDelete(new File("build/testCache2"));
    // now do a new resolve: it should use cached data
    report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), report.getConfigurationReport("default").getModuleRevisionIds());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Aggregations

ResolveReport (org.apache.ivy.core.report.ResolveReport)278 Test (org.junit.Test)259 File (java.io.File)253 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)218 JarFile (java.util.jar.JarFile)199 Ivy (org.apache.ivy.Ivy)102 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)101 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)94 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)15 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)13 BuildException (org.apache.tools.ant.BuildException)9 URL (java.net.URL)8 HashMap (java.util.HashMap)8 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)8 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)7 Artifact (org.apache.ivy.core.module.descriptor.Artifact)7 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)6