Search in sources :

Example 61 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class ResolveTest method testChangeCacheLayout.

@Test
public void testChangeCacheLayout() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/ivysettings.xml"));
    DefaultRepositoryCacheManager cacheMgr = (DefaultRepositoryCacheManager) ivy.getSettings().getDefaultRepositoryCacheManager();
    cacheMgr.setIvyPattern("[module]/ivy.xml");
    cacheMgr.setArtifactPattern("[artifact].[ext]");
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(ivy, mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ivy, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
    assertTrue(new File(cache, "mod1.2/ivy.xml").exists());
    assertTrue(getArchiveFileInCache(ivy, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
    assertTrue(new File(cache, "mod1.2.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) DefaultRepositoryCacheManager(org.apache.ivy.core.cache.DefaultRepositoryCacheManager) Test(org.junit.Test)

Example 62 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class ResolveTest method testResolveWithExcludesArtifacts5.

@Test
public void testResolveWithExcludesArtifacts5() throws Exception {
    // mod2.3 depends on mod2.1 and excludes artifacts with glob matcher
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.3/ivys/ivy-0.6.5.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.6.5");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists());
    assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists());
    assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists());
    assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "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) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 63 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class ResolveTest method testResolveForceWithDynamicRevisionsAndSeveralConfs.

@Test
public void testResolveForceWithDynamicRevisionsAndSeveralConfs() throws Exception {
    // mod4.1 v 4.6 (conf compile, runtime extends compile, test extends runtime) depends on
    // - mod1.2 v 1+ and forces it in conf compile
    // - mod3.1 v 1.2 in conf test which depends on mod1.2 v 2+
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod4.1/ivy-4.6.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.6");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org3", "mod3.1", "1.2")).exists());
    assertTrue(getArchiveFileInCache("org3", "mod3.1", "1.2", "mod3.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "1.1")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "1.1", "mod1.2", "jar", "jar").exists());
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.2", "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) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 64 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class ResolveTest method testResolveTransitiveExcludesSimple.

@Test
public void testResolveTransitiveExcludesSimple() throws Exception {
    // mod2.5 depends on mod2.3 and excludes one artifact from mod2.1
    // mod2.3 depends on mod2.1
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.5/ivys/ivy-0.6.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.5", "0.6");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.3", "0.7")).exists());
    assertTrue(getArchiveFileInCache("org2", "mod2.3", "0.7", "mod2.3", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists());
    assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists());
    assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "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) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 65 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class ResolveTest method testResolverDirectlyUsingCache.

@Test
public void testResolverDirectlyUsingCache() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(ResolveTest.class.getResource("badcacheconf.xml"));
    File depIvyFileInCache = getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"));
    // creates a
    FileUtil.copy(File.createTempFile("test", "xml"), depIvyFileInCache, null);
    // fake
    // dependency
    // file in cache
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.4/ivys/ivy-0.3.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.4", "0.3");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(depIvyFileInCache.exists());
    assertFalse(getArchiveFileInCache(ivy, "org1", "mod1.1", "1.0", "mod1.1", "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

ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)284 Test (org.junit.Test)233 File (java.io.File)143 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)114 ResolveReport (org.apache.ivy.core.report.ResolveReport)94 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)80 JarFile (java.util.jar.JarFile)76 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)76 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)69 IvySettings (org.apache.ivy.core.settings.IvySettings)60 XmlModuleDescriptorParserTest (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest)44 Configuration (org.apache.ivy.core.module.descriptor.Configuration)30 Artifact (org.apache.ivy.core.module.descriptor.Artifact)28 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)27 IOException (java.io.IOException)24 ParseException (java.text.ParseException)23 Ivy (org.apache.ivy.Ivy)23 BufferedReader (java.io.BufferedReader)19 FileReader (java.io.FileReader)19 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)17