use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class IvyDeliverTest method testWithDynEvicted2.
/**
* Test case for IVY-707.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-707">IVY-707</a>
*/
@Test
public void testWithDynEvicted2() throws Exception {
// same as previous but dynamic dependency is placed after the one causing the conflict
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-dyn-evicted2.xml");
IvyResolve res = new IvyResolve();
res.setValidate(false);
res.setProject(project);
res.execute();
deliver.setPubrevision("1.2");
deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
deliver.setValidate(false);
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(), false);
assertEquals(ModuleRevisionId.newInstance("apache", "resolve-latest", "1.2"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertEquals(2, dds.length);
assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2"), dds[1].getDependencyRevisionId());
IvyRetrieve ret = new IvyRetrieve();
ret.setProject(project);
ret.setPattern("build/test/retrieve/[artifact]-[revision].[ext]");
ret.execute();
File list = new File("build/test/retrieve");
String[] files = list.list();
HashSet<String> actualFileSet = new HashSet<>(Arrays.asList(files));
HashSet<String> expectedFileSet = new HashSet<>();
for (DependencyDescriptor dd : dds) {
String name = dd.getDependencyId().getName();
String rev = dd.getDependencyRevisionId().getRevision();
String ext = "jar";
String artifact = name + "-" + rev + "." + ext;
expectedFileSet.add(artifact);
}
assertEquals("Delivered Ivy descriptor inconsistent with retrieved artifacts", expectedFileSet, actualFileSet);
list.delete();
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class IvyDeliverTest method testNotGenerateRevConstraint.
@Test
public void testNotGenerateRevConstraint() 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.setGenerateRevConstraint(false);
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", "2.2"), dds[0].getDynamicConstraintDependencyRevisionId());
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class IvyDeliverTest method testWithResolveId.
@Test
public void testWithResolveId() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
resolve.setResolveId("withResolveId");
resolve.execute();
// resolve another ivy file
resolve = new IvyResolve();
resolve.setProject(project);
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-latest.xml"));
resolve.execute();
deliver.setResolveId("withResolveId");
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-simple", "1.2"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertEquals(1, dds.length);
assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"), dds[0].getDependencyRevisionId());
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class IvyDeliverTest method testReplaceBranch.
@Test
public void testReplaceBranch() throws Exception {
IvyConfigure settings = new IvyConfigure();
settings.setProject(project);
settings.execute();
// change the default branch to use
IvyAntSettings.getDefaultInstance(settings).getConfiguredIvyInstance(settings).getSettings().setDefaultBranch("BRANCH1");
// resolve a module dependencies
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
IvyResolve res = new IvyResolve();
res.setProject(project);
res.execute();
// deliver this module
deliver.setPubrevision("1.2");
deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
deliver.execute();
// should have done the ivy delivering, including setting the branch according to the
// configured default
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", "BRANCH1", "2.2"), dds[0].getDependencyRevisionId());
assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "latest.integration"), dds[0].getDynamicConstraintDependencyRevisionId());
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class IvyDeliverTest method testDifferentRevisionsForSameModule.
@Test
public void testDifferentRevisionsForSameModule() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-different-revisions.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", "different-revs", "1.2"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertEquals(3, dds.length);
assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"), dds[0].getDependencyRevisionId());
assertEquals(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), dds[1].getDependencyRevisionId());
assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "1.1"), dds[2].getDependencyRevisionId());
}
Aggregations