Search in sources :

Example 21 with Ivy

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

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

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

Example 24 with Ivy

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

the class ResolveTest method testResolveMaven2ParentPomWithNamespace.

/**
 * Test case for IVY-1186.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1186">IVY-1186</a>
 */
@Test
public void testResolveMaven2ParentPomWithNamespace() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/parentPom/ivysettings-namespace.xml"));
    ResolveReport report = ivy.resolve(ModuleRevisionId.newInstance("org.apache.systemDm", "test", "1.0"), getResolveOptions(new String[] { "*(public)" }), true);
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    // assertEquals(mrid, md.getModuleRevisionId());
    // assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // test the report to make sure the right dependencies are listed
    List<IvyNode> dependencies = report.getDependencies();
    // the test module + it's 2 dependencies
    assertEquals(3, dependencies.size());
    IvyNode ivyNode = dependencies.get(0);
    assertNotNull(ivyNode);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.systemDm", "test", "1.0");
    assertEquals(mrid, ivyNode.getId());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache.systemDm", "test", "1.0")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache.systemDm", "test", "1.0", "test", "jar", "jar").exists());
    ivyNode = dependencies.get(1);
    assertNotNull(ivyNode);
    mrid = ModuleRevisionId.newInstance("org.apache.systemDm", "test2", "2.0");
    assertEquals(mrid, ivyNode.getId());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache.systemDm", "test2", "2.0")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache.systemDm", "test2", "2.0", "test2", "jar", "jar").exists());
    ivyNode = dependencies.get(2);
    assertNotNull(ivyNode);
    mrid = ModuleRevisionId.newInstance("org.apache.systemDm", "test3", "1.0");
    assertEquals(mrid, ivyNode.getId());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache.systemDm", "test3", "1.0")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache.systemDm", "test3", "1.0", "test3", "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 25 with Ivy

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

the class ResolveTest method testResolveMaven2.

@Test
public void testResolveMaven2() throws Exception {
    // test3 depends on test2 which depends on test
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/m2/org/apache/test3/1.0/test3-1.0.pom"), getResolveOptions(new String[] { "test" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test3", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test2", "1.0")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test2", "1.0", "test2", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test", "1.0")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test", "1.0", "test", "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)

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