use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testConfigurationMapping5.
/**
* Test case for IVY-84.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-84">IVY-84</a>
*/
@Test
public void testConfigurationMapping5() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-84/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File("test/repositories/IVY-84/tests/5/ivy.xml"), getResolveOptions(new String[] { "*" }));
ConfigurationResolveReport conf = report.getConfigurationReport("default");
assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf);
assertDoesntContainArtifact("test", "a", "1.0.2", "a-bt", "txt", "txt", conf);
assertContainsArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf);
assertDoesntContainArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf);
assertContainsArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf);
assertDoesntContainArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf);
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testNamespaceMapping4.
@Test
public void testNamespaceMapping4() throws Exception {
// same as 2 but with incorrect dependency asked: the first ivy file asks for a dependency
// in the resolver namespace and not the system one: this should fail
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/namespace/ivysettings.xml"));
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-namespace4.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("apache", "namespace", "4.0");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(report.hasError());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testExtraAttributes.
@Test
public void testExtraAttributes() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));
ivy.getSettings().setDefaultCache(cache);
FileSystemResolver fResolver = (FileSystemResolver) ivy.getSettings().getDefaultResolver();
// important for testing IVY-929
fResolver.setCheckconsistency(false);
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
assertFalse(report.hasError());
assertTrue(new File(cache, "apache/mymodule/task1/1854/ivy.xml").exists());
assertTrue(new File(cache, "apache/mymodule/task1/1854/mymodule-windows.jar").exists());
assertTrue(new File(cache, "apache/mymodule/task1/1854/mymodule-linux.jar").exists());
Set<ModuleRevisionId> moduleRevisions = report.getConfigurationReport("default").getModuleRevisionIds();
assertEquals(1, moduleRevisions.size());
ModuleRevisionId resolveModRevId = moduleRevisions.iterator().next();
assertEquals("apache", resolveModRevId.getOrganisation());
assertEquals("mymodule", resolveModRevId.getName());
assertEquals("1854", resolveModRevId.getRevision());
assertEquals("task1", resolveModRevId.getExtraAttribute("eatt"));
assertEquals("another", resolveModRevId.getExtraAttribute("eatt2"));
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testChangeCacheLayout.
@Test
public void testChangeCacheLayout() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/ivysettings.xml"));
DefaultRepositoryCacheManager cacheMgr = (DefaultRepositoryCacheManager) ivy.getSettings().getDefaultRepositoryCacheManager();
cacheMgr.setIvyPattern("[module]/ivy.xml");
cacheMgr.setArtifactPattern("[artifact].[ext]");
// mod1.1 depends on mod1.2
ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(ivy.getSettings(), 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(ivy, mrid).exists());
// dependencies
assertTrue(getIvyFileInCache(ivy, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
assertTrue(new File(cache, "mod1.2/ivy.xml").exists());
assertTrue(getArchiveFileInCache(ivy, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
assertTrue(new File(cache, "mod1.2.jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testResolveMaven2RelocationOfGroupId.
@Test
public void testResolveMaven2RelocationOfGroupId() throws Exception {
// Same as testResolveMaven2 but with a relocated module pointing to the module
// used in testResolveMaven2.
ivy = new Ivy();
ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
ivy.pushContext();
try {
ResolveReport report = ivy.resolve(new File("test/repositories/m2/org/relocated/test3/1.0/test3-1.0.pom"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test2", "1.0")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache", "test2", "1.0", "test2", "jar", "jar").exists());
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test", "1.0")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache", "test", "1.0", "test", "jar", "jar").exists());
} finally {
ivy.popContext();
}
}
Aggregations