use of org.apache.ivy.Ivy in project Saturn by vipshop.
the class MavenProjectUtils method getIvyGetArtifact.
public IvyGetArtifact getIvyGetArtifact() throws ParseException, IOException {
// ivy下包缓存目录
File cacheDirectory = new File(ivyCache);
if (!cacheDirectory.exists()) {
cacheDirectory.mkdirs();
}
URL settingsURL = MavenProjectUtils.class.getClassLoader().getResource("ivysettings.xml");
Ivy ivy = Ivy.newInstance();
ivy.getSettings().setDefaultCache(cacheDirectory);
ivy.getSettings().setVariable("ivy.local.default.root", localRepository);
ivy.getSettings().load(settingsURL);
return new IvyGetArtifact(logger, ivy);
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testDynamicFromCacheWithMD.
@Test
public void testDynamicFromCacheWithMD() throws Exception {
// same as above, but this time the dependency has a module descriptor
// mod1.4;1.0.2 depends on mod1.2;[1.0,2.0[
Ivy ivy = ivyTestCache();
ivy.getSettings().setVariable("ivy.cache.ttl.default", "10s", true);
// set up repository
FileUtil.forceDelete(new File("build/testCache2"));
FileUtil.copy(ResolveTest.class.getResourceAsStream("ivy-mod1.2-1.5.xml"), new File("build/testCache2/ivy-mod1.2-1.5.xml"), null);
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 clean the repository to simulate repo not available (network pb for instance)
FileUtil.forceDelete(new File("build/testCache2"));
// now do a new resolve: it should 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.5")), report.getConfigurationReport("default").getModuleRevisionIds());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testRefreshDynamicFromCache.
@Test
public void testRefreshDynamicFromCache() 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", "10s", 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());
// 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 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.5")), report.getConfigurationReport("default").getModuleRevisionIds());
// resolve again with refresh: it should find the new version
report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] { "*" }).setRefresh(true));
assertFalse(report.hasError());
assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.6")), report.getConfigurationReport("default").getModuleRevisionIds());
FileUtil.forceDelete(new File("build/testCache2"));
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testResolveNoRevisionInPattern.
@Test
public void testResolveNoRevisionInPattern() throws Exception {
// module1 depends on latest version of module2, for which there is no revision in the
// pattern
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/norev/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File("test/repositories/norev/ivy.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
assertFalse(report.hasError());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testConfigurationMapping1.
// /////////////////////////////////////////////////////////
// here comes a series of test provided by Chris Rudd
// about configuration mapping and eviction
// /////////////////////////////////////////////////////////
/**
* 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 testConfigurationMapping1() 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/1/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.2", "b", "txt", "txt", conf);
assertDoesntContainArtifact("test", "b", "1.0.2", "b-bt", "txt", "txt", conf);
assertContainsArtifact("test", "c", "1.0.2", "c", "txt", "txt", conf);
assertDoesntContainArtifact("test", "c", "1.0.2", "c-bt", "txt", "txt", conf);
}
Aggregations