Search in sources :

Example 46 with Ivy

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

the class ResolveTest method testIVY151.

/**
 * Test case for IVY-1151.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1151">IVY-1151</a>
 */
@Test
public void testIVY151() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/multirevisions/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/multirevisions/ivy.xml"), getResolveOptions(new String[] { "compile", "test" }));
    assertNotNull(report);
    assertNotNull(report.getUnresolvedDependencies());
    assertEquals("Number of unresolved dependencies not correct", 0, report.getUnresolvedDependencies().length);
}
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 47 with Ivy

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

the class ResolveTest method testResolveModeDynamicWithBranch2.

@Test
public void testResolveModeDynamicWithBranch2() throws Exception {
    // bar1;5 -> foo1#trunk|branch1;3|[0,4]
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/branches/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/branches/bar/bar1/trunk/6/ivy.xml"), getResolveOptions(new String[] { "*" }).setResolveMode(ResolveOptions.RESOLVEMODE_DYNAMIC));
    assertFalse(report.hasError());
    assertTrue(getArchiveFileInCache(ivy, "foo#foo1#branch1;4", "foo1", "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 48 with Ivy

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

the class ResolveTest method testResolveTransitivelyToRelocatedPom.

@Test
public void testResolveTransitivelyToRelocatedPom() throws Exception {
    ivy = new Ivy();
    ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
    ivy.pushContext();
    try {
        ResolveReport report = ivy.resolve(new File("test/repositories/m2/org/relocated/testRelocationUser/1.0/" + "testRelocationUser-1.0.pom"), getResolveOptions(new String[] { "compile" }));
        assertNotNull(report);
        assertFalse(report.hasError());
        // 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());
    } finally {
        ivy.popContext();
    }
}
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 49 with Ivy

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

the class ResolveTest method testResolveNoRevisionNowhere.

/**
 * Test case for IVY-258.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-258">IVY-258</a>
 */
@Test
public void testResolveNoRevisionNowhere() throws Exception {
    // module1 depends on latest version of module2, which contains no revision in its ivy file,
    // nor in the pattern
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/IVY-258/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/IVY-258/ivy.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    ((BasicResolver) ivy.getSettings().getResolver("myresolver")).setCheckconsistency(false);
    report = ivy.resolve(new File("test/repositories/IVY-258/ivy.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) BasicResolver(org.apache.ivy.plugins.resolver.BasicResolver) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 50 with Ivy

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

the class ResolveTest method testBranches2.

@Test
public void testBranches2() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/branches/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/branches/bar/bar1/trunk/2/ivy.xml"), getResolveOptions(new String[] { "*" }).setValidate(false));
    assertFalse(report.hasError());
    assertTrue(getArchiveFileInCache(ivy, "foo#foo1#branch1;4", "foo1", "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