Search in sources :

Example 51 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class ResolveTest method testResolveMaven2Snapshot2AsLatestIntegration.

/**
 * 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 testResolveMaven2Snapshot2AsLatestIntegration() 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-SNAPSHOT2", "latest.integration"), getResolveOptions(new String[] { "*(public)" }), true);
    assertNotNull(report);
    assertFalse(report.hasError());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT2", "2.0.2-SNAPSHOT")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-SNAPSHOT2", "2.0.2-SNAPSHOT", "test-SNAPSHOT2", "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)

Example 52 with Ivy

use of org.apache.ivy.Ivy 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 53 with Ivy

use of org.apache.ivy.Ivy 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 54 with Ivy

use of org.apache.ivy.Ivy 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 55 with Ivy

use of org.apache.ivy.Ivy 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

Ivy (org.apache.ivy.Ivy)169 File (java.io.File)147 Test (org.junit.Test)137 ResolveReport (org.apache.ivy.core.report.ResolveReport)102 JarFile (java.util.jar.JarFile)100 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)97 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)40 IvySettings (org.apache.ivy.core.settings.IvySettings)26 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)23 BuildException (org.apache.tools.ant.BuildException)17 Before (org.junit.Before)12 HashMap (java.util.HashMap)9 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)8 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)6 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)6 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)5 ModuleId (org.apache.ivy.core.module.id.ModuleId)5 IOException (java.io.IOException)4 ParseException (java.text.ParseException)4 Date (java.util.Date)4