use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class UpdateSiteAndIbiblioResolverTest method setUp.
@Before
public void setUp() throws Exception {
settings = new IvySettings();
chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
resolver = new UpdateSiteResolver();
resolver.setName("ivyde-repo");
resolver.setUrl(new File("test/test-p2/ivyde-repo").toURI().toURL().toExternalForm());
resolver.setSettings(settings);
resolver2 = new IBiblioResolver();
resolver2.setName("maven2");
settings.setVariable("ivy.ibiblio.default.artifact.root", DEFAULT_M2_ROOT);
settings.setVariable("ivy.ibiblio.default.artifact.pattern", "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
resolver2.setSettings(settings);
chain.add(resolver);
chain.add(resolver2);
settings.addResolver(chain);
settings.setDefaultResolver("chain");
cache = new File("build/cache");
cache.mkdirs();
settings.setDefaultCache(cache);
ivy = new Ivy();
ivy.setSettings(settings);
ivy.bind();
ivy.getResolutionCacheManager().clean();
RepositoryCacheManager[] caches = settings.getRepositoryCacheManagers();
for (RepositoryCacheManager cache : caches) {
cache.clean();
}
data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class LatestConflictManagerTest method setUp.
@Before
public void setUp() throws Exception {
ivy = new Ivy();
ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest.xml"));
cache = new File("build/cache");
cache.mkdirs();
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class LatestConflictManagerTest method testLatestTimeTransitivity.
/**
* Test case for IVY-407 (with transitivity). There are 5 modules A, B, C, D and E.
* <ol>
* <li>publish C-1.0.0, C-1.0.1 and C-1.0.2</li>
* <li>B needs C-1.0.0 : retrieve ok and publish B-1.0.0</li>
* <li>A needs B-1.0.0 and C-1.0.2 : retrieve ok and publish A-1.0.0</li>
* <li>D needs C-1.0.1 : retrieve ok and publish D-1.0.0</li>
* <li>E needs D-1.0.0 and A-1.0.0 (D before A in ivy file) :
* retrieve failed to get C-1.0.2 from A (get apparently C-1.0.1 from D)</li>
* </ol>
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-407">IVY-407</a>
*/
@Test
public void testLatestTimeTransitivity() throws Exception {
ivy = new Ivy();
ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time-transitivity.xml"));
ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);
// set timestamps, because svn is not preserving this information,
// and the latest time strategy is relying on it
long time = System.currentTimeMillis() - 10000;
new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.0.xml").setLastModified(time);
new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.1.xml").setLastModified(time + 2000);
new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.2.xml").setLastModified(time + 4000);
ResolveReport report = ivy.resolve(LatestConflictManagerTest.class.getResource("ivy-latest-time-transitivity.xml"), getResolveOptions());
ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
switch(mrid.getName()) {
case "A":
assertEquals("A revision should be 1.0.0", "1.0.0", mrid.getRevision());
break;
case "B":
// by transitivity
assertEquals("B revision should be 1.0.0", "1.0.0", mrid.getRevision());
break;
case "C":
assertEquals("C revision should be 1.0.2", "1.0.2", mrid.getRevision());
break;
case "D":
assertEquals("D revision should be 1.0.0", "1.0.0", mrid.getRevision());
break;
}
}
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class RegexpConflictManagerTest method setUp.
@Before
public void setUp() throws Exception {
ivy = new Ivy();
ivy.configure(RegexpConflictManagerTest.class.getResource("ivysettings-regexp-test.xml"));
cache = new File("build/cache");
cache.mkdirs();
}
use of org.apache.ivy.Ivy in project gradle by gradle.
the class DefaultIvyContextManager method withIvy.
@Override
public <T> T withIvy(Transformer<? extends T, ? super Ivy> action) {
Integer currentDepth = depth.get();
if (currentDepth != null) {
depth.set(currentDepth + 1);
try {
return action.transform(IvyContext.getContext().getIvy());
} finally {
depth.set(currentDepth);
}
}
IvyContext.pushNewContext();
try {
depth.set(1);
try {
Ivy ivy = getIvy();
try {
IvyContext.getContext().setIvy(ivy);
return action.transform(ivy);
} finally {
releaseIvy(ivy);
}
} finally {
depth.remove();
}
} finally {
IvyContext.popContext();
}
}
Aggregations