Search in sources :

Example 21 with ModuleDescriptor

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

the class FixDepsTaskTest method testFixedResolve.

@Test
public void testFixedResolve() throws Exception {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-transitive.xml");
    File dest = new File("build/testFixDeps/testTransitivity.xml");
    fixDeps.setToFile(dest);
    fixDeps.execute();
    project.setProperty("ivy.dep.file", dest.getAbsolutePath());
    File dest2 = new File("build/testFixDeps/testTransitivity2.xml");
    fixDeps.setToFile(dest2);
    fixDeps.execute();
    ModuleDescriptor md1 = XmlModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), dest.toURI().toURL(), true);
    ModuleDescriptor md2 = XmlModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), dest2.toURI().toURL(), true);
    assertEquals(md1, md2);
    assertEquals(Arrays.asList(md1.getConfigurations()), Arrays.asList(md2.getConfigurations()));
    assertEquals(toString(Arrays.asList(md1.getDependencies())), toString(Arrays.asList(md2.getDependencies())));
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Test(org.junit.Test)

Example 22 with ModuleDescriptor

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

the class FixDepsTaskTest method testMulticonf.

@Test
public void testMulticonf() throws Exception {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml");
    File dest = new File("build/testFixDeps/testMultiConf.xml");
    fixDeps.setToFile(dest);
    fixDeps.execute();
    assertTrue(dest.exists());
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), dest.toURI().toURL(), true);
    assertEquals("apache", md.getModuleRevisionId().getOrganisation());
    assertEquals("resolve-simple", md.getModuleRevisionId().getName());
    assertEquals("1.0", md.getModuleRevisionId().getRevision());
    assertEquals("release", md.getStatus());
    assertEquals(2, md.getConfigurations().length);
    assertEquals("default", md.getConfigurations()[0].getName());
    assertEquals(0, md.getConfigurations()[0].getExtends().length);
    assertEquals("compile", md.getConfigurations()[1].getName());
    assertEquals(0, md.getConfigurations()[1].getExtends().length);
    assertEquals(2, md.getDependencies().length);
    assertEquals("org1", md.getDependencies()[0].getDependencyId().getOrganisation());
    assertEquals("mod1.2", md.getDependencies()[0].getDependencyId().getName());
    assertFalse(md.getDependencies()[0].isChanging());
    assertTrue(md.getDependencies()[0].isForce());
    assertFalse(md.getDependencies()[0].isTransitive());
    assertEquals("2.0", md.getDependencies()[0].getDependencyRevisionId().getRevision());
    assertEquals(1, md.getDependencies()[0].getModuleConfigurations().length);
    assertEquals("default", md.getDependencies()[0].getModuleConfigurations()[0]);
    assertEquals(1, md.getDependencies()[0].getDependencyConfigurations("default").length);
    assertEquals("default", md.getDependencies()[0].getDependencyConfigurations("default")[0]);
    assertEquals("org1", md.getDependencies()[1].getDependencyId().getOrganisation());
    assertEquals("mod1.1", md.getDependencies()[1].getDependencyId().getName());
    assertFalse(md.getDependencies()[1].isChanging());
    assertTrue(md.getDependencies()[1].isForce());
    assertFalse(md.getDependencies()[1].isTransitive());
    assertEquals("2.0", md.getDependencies()[1].getDependencyRevisionId().getRevision());
    assertEquals(1, md.getDependencies()[1].getModuleConfigurations().length);
    assertEquals("compile", md.getDependencies()[1].getModuleConfigurations()[0]);
    assertEquals(1, md.getDependencies()[1].getDependencyConfigurations("compile").length);
    assertEquals("default", md.getDependencies()[1].getDependencyConfigurations("compile")[0]);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Test(org.junit.Test)

Example 23 with ModuleDescriptor

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

the class IvyDeliverTest method testWithBranch.

/**
 * Test case for IVY-404.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-404">IVY-404</a>
 */
@Test
public void testWithBranch() throws Exception {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest-branch.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();
    deliver.setPubrevision("1.2");
    deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
    deliver.execute();
    // should have done the ivy delivering
    File deliveredIvyFile = new File("build/test/deliver/ivy-1.2.xml");
    assertTrue(deliveredIvyFile.exists());
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), deliveredIvyFile.toURI().toURL(), true);
    assertEquals(ModuleRevisionId.newInstance("apache", "resolve-latest", "1.2"), md.getModuleRevisionId());
    DependencyDescriptor[] dds = md.getDependencies();
    assertEquals(1, dds.length);
    assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "TRUNK", "2.2"), dds[0].getDependencyRevisionId());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Test(org.junit.Test)

Example 24 with ModuleDescriptor

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

the class IvyDeliverTest method testReplaceBranchInfo.

@Test
public void testReplaceBranchInfo() throws Exception {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();
    deliver.setPubrevision("1.2");
    deliver.setPubbranch("BRANCH1");
    deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
    deliver.execute();
    // should have done the ivy delivering
    File deliveredIvyFile = new File("build/test/deliver/ivy-1.2.xml");
    assertTrue(deliveredIvyFile.exists());
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), deliveredIvyFile.toURI().toURL(), true);
    assertEquals(ModuleRevisionId.newInstance("apache", "resolve-latest", "BRANCH1", "1.2"), md.getModuleRevisionId());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Test(org.junit.Test)

Example 25 with ModuleDescriptor

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

the class IvyDeliverTest method testSimple.

@Test
public void testSimple() throws Exception {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();
    deliver.setPubrevision("1.2");
    deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
    deliver.execute();
    // should have done the ivy delivering
    File deliveredIvyFile = new File("build/test/deliver/ivy-1.2.xml");
    assertTrue(deliveredIvyFile.exists());
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), deliveredIvyFile.toURI().toURL(), true);
    assertEquals(ModuleRevisionId.newInstance("apache", "resolve-latest", "1.2"), md.getModuleRevisionId());
    DependencyDescriptor[] dds = md.getDependencies();
    assertEquals(1, dds.length);
    assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2"), dds[0].getDependencyRevisionId());
    assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "latest.integration"), dds[0].getDynamicConstraintDependencyRevisionId());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) IvySettings(org.apache.ivy.core.settings.IvySettings) 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