Search in sources :

Example 51 with ModuleDescriptor

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

the class ResolveTest method testResolveSimple.

@Test
public void testResolveSimple() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(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(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) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 52 with ModuleDescriptor

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

the class ResolveTest method testResolveExcludesConf2.

@Test
public void testResolveExcludesConf2() throws Exception {
    // same as testResolveExcludesConf
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.6/ivys/ivy-0.13.xml"), getResolveOptions(new String[] { "exclude" }));
    ModuleDescriptor md = report.getModuleDescriptor();
    assertEquals(ModuleRevisionId.newInstance("org2", "mod2.6", "0.13"), md.getModuleRevisionId());
    assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.3", "0.4")).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) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 53 with ModuleDescriptor

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

the class ResolveTest method testResolveWithStartPublicConf.

@Test
public void testResolveWithStartPublicConf() throws Exception {
    // mod2.2 depends on mod1.3 and selects its artifacts
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.2/ivys/ivy-0.8.xml"), getResolveOptions(new String[] { "*(public)" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.2", "0.8");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.3", "3.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-A", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar").exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "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 54 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor 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 55 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor 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)

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