Search in sources :

Example 31 with ResolveReport

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

the class ResolveTest method testMultipleCache.

@Test
public void testMultipleCache() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/ivysettings-multicache.xml"));
    // 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.3.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    assertFalse(report.hasError());
    // dependencies
    DefaultArtifact depArtifact = TestHelper.newArtifact("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar");
    ModuleRevisionId depMrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    DefaultRepositoryCacheManager cacheMgr1 = (DefaultRepositoryCacheManager) ivy.getSettings().getDefaultRepositoryCacheManager();
    DefaultRepositoryCacheManager cacheMgr2 = (DefaultRepositoryCacheManager) ivy.getSettings().getRepositoryCacheManager("cache2");
    // ivy file should be cached in default cache, and artifact in cache2
    assertTrue(cacheMgr1.getIvyFileInCache(depMrid).exists());
    assertFalse(cacheMgr1.getArchiveFileInCache(depArtifact).exists());
    assertEquals(new File(cache, "repo1/mod1.1/ivy-1.0.xml").getCanonicalFile(), cacheMgr1.getIvyFileInCache(depMrid).getCanonicalFile());
    assertFalse(cacheMgr2.getIvyFileInCache(depMrid).exists());
    assertTrue(cacheMgr2.getArchiveFileInCache(depArtifact).exists());
    assertEquals(new File(cache, "repo2/mod1.1-1.0/mod1.1.jar").getCanonicalFile(), cacheMgr2.getArchiveFileInCache(depArtifact).getCanonicalFile());
}
Also used : 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) DefaultRepositoryCacheManager(org.apache.ivy.core.cache.DefaultRepositoryCacheManager) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 32 with ResolveReport

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

the class ResolveTest method testResolveMaven2WithVersionProperty.

@Test
public void testResolveMaven2WithVersionProperty() throws Exception {
    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-version/1.0/test-version-1.0.pom"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test-version", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test-classifier", "1.0")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-classifier", "1.0", "test-classifier", "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 33 with ResolveReport

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

the class ResolveTest method testRegularCircular.

@Test
public void testRegularCircular() throws Exception {
    // mod11.1 depends on mod11.2 but excludes itself
    // mod11.2 depends on mod11.1
    ivy.getSettings().setCircularDependencyStrategy(ErrorCircularDependencyStrategy.getInstance());
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod11.1/ivy-1.0.xml"), getResolveOptions(new String[] { "test" }));
    assertNotNull(report);
    assertFalse(report.hasError());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org11", "mod11.2", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org11", "mod11.2", "1.0", "mod11.2", "jar", "jar").exists());
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org11", "mod11.1", "1.0")).exists());
    assertFalse(getArchiveFileInCache("org11", "mod11.1", "1.0", "mod11.1", "jar", "jar").exists());
}
Also used : 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 34 with ResolveReport

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

the class ResolveTest method testConfigurationMapping4.

/**
 * 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 testConfigurationMapping4() 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/4/ivy.xml"), getResolveOptions(new String[] { "default" }));
    ConfigurationResolveReport conf = report.getConfigurationReport("default");
    assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "a", "1.0.2", "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 35 with ResolveReport

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

the class ResolveTest method testResolveMaven2Snapshot1AsLatestIntegration.

/**
 * Test case for IVY-1036.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1036">IVY-1036</a>
 */
@Test
public void testResolveMaven2Snapshot1AsLatestIntegration() throws Exception {
    // here we test maven SNAPSHOT versions handling,
    // with m2 snapshotRepository/uniqueVersion set to true
    // but retrieving by latest.integration
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
    ResolveReport report = ivy.resolve(ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT1", "latest.integration"), getResolveOptions(new String[] { "*(public)" }), true);
    assertNotNull(report);
    assertFalse(report.hasError());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT1", "2.0.2-SNAPSHOT")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-SNAPSHOT1", "2.0.2-SNAPSHOT", "test-SNAPSHOT1", "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