Search in sources :

Example 36 with Ivy

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

the class ResolveTest method testExtraAttributesMultipleDependenciesHang2.

@Test
public void testExtraAttributesMultipleDependenciesHang2() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/extra-attributes-multipledependencies/ivysettings-filerepo-attribs.xml"));
    ivy.getSettings().setDefaultCache(cache);
    ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att-multipledependencies2.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
    assertFalse(report.hasError());
}
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 37 with Ivy

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

the class ResolveTest method testResolveWithDynamicRevisionsAndArtifactLockStrategy.

@Test
public void testResolveWithDynamicRevisionsAndArtifactLockStrategy() throws Exception {
    // mod4.1 v 4.5 depends on
    // - mod1.2 v 1+ and forces it
    // - mod3.1 v 1.2 which depends on mod1.2 v 2+
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/ivysettings-artifact-lock.xml"));
    ivy.resolve(new File("test/repositories/2/mod4.1/ivy-4.5.xml"), getResolveOptions(new String[] { "*" }));
    List<File> lockFiles = new ArrayList<>();
    findLockFiles(cache, lockFiles);
    assertTrue("There were lockfiles left in the cache: " + lockFiles, lockFiles.isEmpty());
}
Also used : ArrayList(java.util.ArrayList) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 38 with Ivy

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

the class ResolveTest method testDynamicFromCache.

@Test
public void testDynamicFromCache() throws Exception {
    // mod1.4;1.0.2 depends on mod1.2;[1.0,2.0[
    Ivy ivy = ivyTestCache();
    ivy.getSettings().setVariable("ivy.cache.ttl.default", "10s", true);
    // set up repository
    FileUtil.forceDelete(new File("build/testCache2"));
    FileUtil.copy(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), new File("build/testCache2/mod1.2-1.5.jar"), null);
    // we first do a simple resolve so that module is in cache
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), report.getConfigurationReport("default").getModuleRevisionIds());
    // 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.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), report.getConfigurationReport("default").getModuleRevisionIds());
}
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 39 with Ivy

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

the class ResolveTest method testBranches1.

@Test
public void testBranches1() 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/1/ivy.xml"), getResolveOptions(new String[] { "*" }).setValidate(false));
    assertFalse(report.hasError());
    assertTrue(getArchiveFileInCache(ivy, "foo#foo1#trunk;3", "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 40 with Ivy

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

the class ResolveTest method testResolveMaven2WithConflict.

@Test
public void testResolveMaven2WithConflict() 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/test3/1.1/test3-1.1.pom"), getResolveOptions(new String[] { "default" }));
    assertFalse(report.hasError());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test2", "1.1")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test2", "1.1", "test2", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test", "1.1")).exists());
    assertTrue(getArchiveFileInCache(ivy, "org.apache", "test", "1.1", "test", "jar", "jar").exists());
    assertContainsArtifact(report.getConfigurationReport("default"), getArtifact("org.apache", "test2", "1.1", "test2", "jar", "jar"));
    assertContainsArtifact(report.getConfigurationReport("default"), getArtifact("org.apache", "test", "1.1", "test", "jar", "jar"));
}
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