use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testResolveMaven2ParentPomChainResolver.
@Test
public void testResolveMaven2ParentPomChainResolver() throws Exception {
// test has a dependency on test2 but there is no version listed. test has a parent of
// parent(2.0)
// then parent2. Both parents have a dependencyManagement element for test2, and each list
// the version as
// ${pom.version}. The parent version should take precedence over parent2,
// so the version should be test2 version 2.0. Test3 is also a dependency of parent, and
// it's version is listed
// as 1.0 in parent2 (dependencies inherited from parent comes after).
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/parentPom/ivysettings.xml"));
ivy.getSettings().setDefaultResolver("parentChain");
ResolveReport report = ivy.resolve(new File("test/repositories/parentPom/org/apache/dm/test/1.0/test-1.0.pom"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.dm", "test", "1.0");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(mrid).exists());
// test the report to make sure the right dependencies are listed
List<IvyNode> dependencies = report.getDependencies();
assertEquals(2, dependencies.size());
IvyNode ivyNode;
ivyNode = dependencies.get(0);
assertNotNull(ivyNode);
// Bad assertions based on IVY-1301 bug, corrected below:
// mrid = ModuleRevisionId.newInstance("org.apache.dm", "test2", "2.0");
// assertEquals(mrid, ivyNode.getId());
// // dependencies
// assertTrue(getIvyFileInCache(
// ModuleRevisionId.newInstance("org.apache.dm", "test2", "2.0")).exists());
// assertTrue(getArchiveFileInCache(ivy, "org.apache.dm", "test2", "2.0",
// "test2", "jar", "jar").exists());
mrid = ModuleRevisionId.newInstance("org.apache.dm", "test2", "1.0");
assertEquals(mrid, ivyNode.getId());
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache.dm", "test2", "1.0")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache.dm", "test2", "1.0", "test2", "jar", "jar").exists());
ivyNode = dependencies.get(1);
assertNotNull(ivyNode);
mrid = ModuleRevisionId.newInstance("org.apache.dm", "test3", "1.0");
assertEquals(mrid, ivyNode.getId());
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache.dm", "test3", "1.0")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache.dm", "test3", "1.0", "test3", "jar", "jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testNoAttributesForcedDependencies.
@Test
public void testNoAttributesForcedDependencies() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/extra-attributes-forceddependencies/ivysettings-filerepo-noattribs.xml"));
ivy.getSettings().setDefaultCache(cache);
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-attrib-forced-dependencies.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
assertFalse(report.hasError());
ivy.deliver("1.0.0", deliverDir.getAbsolutePath() + "/ivy-1.0.0.xml", new DeliverOptions().setResolveId(report.getResolveId()).setValidate(false).setPubdate(new Date()));
File deliveredIvyFile = new File(deliverDir, "ivy-1.0.0.xml");
assertTrue(deliveredIvyFile.exists());
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings(), deliveredIvyFile.toURI().toURL(), false);
DependencyDescriptor[] dds = md.getDependencies();
assertEquals(2, dds.length);
assertEquals(ModuleRevisionId.newInstance("CAE-Visualization-Components", "SGL", "MAIN", "6.2.34.7"), dds[1].getDependencyRevisionId());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testExtraAttributes2.
/**
* Test case for IVY-773.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-773">IVY-773</a>
*/
@Test
public void testExtraAttributes2() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));
ivy.getSettings().setDefaultCache(cache);
ivy.getSettings().validate();
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att2.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
assertFalse(report.hasError());
assertTrue(new File(cache, "apache/mymodule/task2/1748/ivy.xml").exists());
assertTrue(new File(cache, "apache/mymodule/task2/1748/ivy.xml.original").exists());
assertTrue(new File(cache, "apache/mymodule/task2/1748/mymodule-windows.jar").exists());
assertTrue(new File(cache, "apache/mymodule/task2/1748/mymodule-linux.jar").exists());
assertTrue(new File(cache, "apache/module2/task2/1976/ivy.xml").exists());
assertTrue(new File(cache, "apache/module2/task2/1976/module2-windows.jar").exists());
assertTrue(new File(cache, "apache/module2/task2/1976/module2-linux.jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testDynamicFromCacheWithTTL0.
@Test
public void testDynamicFromCacheWithTTL0() 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", "0ms", 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 update the repository
FileUtil.copy(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), new File("build/testCache2/mod1.2-1.6.jar"), null);
// now do a new resolve: it should not 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.6")), report.getConfigurationReport("default").getModuleRevisionIds());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testResolveMaven2ParentPomDependencyManagementWithImport.
/**
* Test case for IVY-1376.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1376">IVY-1376</a>
*/
@Test
public void testResolveMaven2ParentPomDependencyManagementWithImport() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/parentPom/ivysettings.xml"));
ivy.getSettings().setDefaultResolver("parentChain");
ResolveReport report = ivy.resolve(new File("test/repositories/parentPom/org/apache/dm/test/3.0/test-3.0.pom"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
// test the report to make sure the right dependencies are listed
List<IvyNode> dependencies = report.getDependencies();
assertFalse(report.hasError());
assertEquals(2, dependencies.size());
IvyNode ivyNode;
ivyNode = dependencies.get(0);
assertNotNull(ivyNode);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.dm", "test5", "2.0");
assertEquals(mrid, ivyNode.getId());
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache.dm", "test5", "2.0")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache.dm", "test5", "2.0", "test5", "jar", "jar").exists());
}
Aggregations