Search in sources :

Example 96 with ResolveReport

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

the class ResolveTest method testResolveTransitiveDependenciesWithOverrideAndDynamicResolveMode.

/**
 * Test case for IVY-1131.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1131">IVY-1131</a>
 */
@Test
public void testResolveTransitiveDependenciesWithOverrideAndDynamicResolveMode() throws Exception {
    // mod2.1 depends on mod1.1 which depends on mod1.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.1/ivys/ivy-0.6.xml"), getResolveOptions(new String[] { "*" }).setResolveMode(ResolveOptions.RESOLVEMODE_DYNAMIC));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.1", "0.6");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "1.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) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 97 with ResolveReport

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

the class ResolveTest method testFromCache2.

@Test
public void testFromCache2() throws Exception {
    // mod1.1 depends on mod1.2
    Ivy ivy = ivyTestCache();
    // set up repository
    FileUtil.forceDelete(new File("build/testCache2"));
    File art = new File("build/testCache2/mod1.2-2.0.jar");
    FileUtil.copy(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), art, null);
    // we first do a simple resolve so that module is in cache
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    // 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.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    ModuleDescriptor md = report.getModuleDescriptor();
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(ivy, mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
    assertTrue(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) 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 98 with ResolveReport

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

the class ResolveTest method testNamespaceExtraAttributes.

@Test
public void testNamespaceExtraAttributes() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));
    ivy.getSettings().setDefaultCache(cache);
    ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att-ns.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(true));
    assertFalse(report.hasError());
    assertTrue(new File(cache, "apache/mymodule/task1/1855/ivy.xml").exists());
    assertTrue(new File(cache, "apache/mymodule/task1/1855/mymodule-windows.jar").exists());
    assertTrue(new File(cache, "apache/mymodule/task1/1855/mymodule-linux.jar").exists());
}
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)

Example 99 with ResolveReport

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

the class ResolveTest method testConfigurationMapping2.

/**
 * Test case for IVY-84.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-84">IVY-84</a>
 */
@Test
public void testConfigurationMapping2() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/IVY-84/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/IVY-84/tests/2/ivy.xml"), getResolveOptions(new String[] { "*" }));
    ConfigurationResolveReport conf = report.getConfigurationReport("default");
    assertContainsArtifact("test", "a", "1.0.1", "a", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "a", "1.0.1", "a-bt", "txt", "txt", conf);
    assertContainsArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf);
    assertContainsArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf);
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 100 with ResolveReport

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

the class ResolveTest method testIVY1178.

/**
 * Test case for IVY-1178.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1178">IVY-1178</a>
 */
@Test
public void testIVY1178() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/IVY-1178/ivysettings.xml"));
    ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-1178.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    assertNotNull(report.getUnresolvedDependencies());
    assertEquals("Number of unresolved dependencies not correct", 0, report.getUnresolvedDependencies().length);
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("myorg", "modD", "1.1")).exists());
    assertTrue(getArchiveFileInCache("myorg", "modD", "1.1", "modD", "jar", "jar").exists());
    // evicted dependencies
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("myorg", "modD", "1.0")).exists());
    assertFalse(getArchiveFileInCache("myorg", "modD", "1.0", "modD", "jar", "jar").exists());
    // transitive dependencies of modD-1.1 (must not exist: transitive="false" !)
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("myorg", "modE", "1.1")).exists());
    assertFalse(getArchiveFileInCache("myorg", "modE", "1.1", "modE", "jar", "jar").exists());
}
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