use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class ResolveTest method testIVY1347.
/**
* Test case for IVY-1347.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1347">IVY-1347</a>
*/
@Test
public void testIVY1347() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-1347/ivysettings.xml"));
ivy.getSettings().setDefaultCache(cache);
ResolveReport rr = ivy.resolve(new File("test/repositories/IVY-1347/childone/childtwo/ivy.xml"), getResolveOptions(new String[] { "*" }));
ModuleDescriptor md = rr.getModuleDescriptor();
assertNotNull(md);
ExtendsDescriptor[] parents = md.getInheritedDescriptors();
assertNotNull(parents);
assertEquals(1, parents.length);
ModuleRevisionId parent = parents[0].getParentRevisionId();
assertEquals(ModuleRevisionId.newInstance("foo", "parent", "1.0"), parent);
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class ResolveTest method testResolveForceWithDynamicRevisions.
@Test
public void testResolveForceWithDynamicRevisions() throws Exception {
// mod4.1 v 4.5 depends on
// - mod1.2 v 1+ and forces it
// - mod3.1 v 1.2 which depends on mod1.2 v 2+
ResolveReport report = ivy.resolve(new File("test/repositories/2/mod4.1/ivy-4.5.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.5");
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());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class ResolveTest method testResolveTransitiveExcludes2.
@Test
public void testResolveTransitiveExcludes2() throws Exception {
// mod2.6 depends on mod2.3 for which it excludes art21A
// mod2.3 depends on mod2.1 and excludes art21B
ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.6/ivys/ivy-0.9.xml"), getResolveOptions(new String[] { "*" }));
ModuleDescriptor md = report.getModuleDescriptor();
assertEquals(ModuleRevisionId.newInstance("org2", "mod2.6", "0.9"), md.getModuleRevisionId());
assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists());
assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class RetrieveTest method testRetrieveOverwrite.
@Test
public void testRetrieveOverwrite() 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").toURI().toURL(), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";
// we create a fake old file to see if it is overwritten
File file = new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")).getCanonicalFile();
file.getParentFile().mkdirs();
file.createNewFile();
ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setOverwriteMode("always").setDestArtifactPattern(pattern));
assertEquals(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").lastModified(), file.lastModified());
}
use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.
the class RetrieveTest method testRetrieveSameFileConflict.
@Test
public void testRetrieveSameFileConflict() throws Exception {
// mod1.1 depends on mod1.2
ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.1.xml").toURI().toURL(), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
String pattern = "build/test/retrieve/[module]/[artifact]-[revision].[ext]";
MockMessageLogger mockLogger = new MockMessageLogger();
Message.setDefaultLogger(mockLogger);
ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setDestArtifactPattern(pattern));
assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar", "default")).exists());
mockLogger.assertLogDoesntContain("conflict on");
}
Aggregations