use of org.apache.ivy.plugins.resolver.DualResolver in project ant-ivy by apache.
the class IvySettings method addResolver.
public synchronized void addResolver(DependencyResolver resolver) {
if (resolver == null) {
throw new NullPointerException("null resolver");
}
init(resolver);
resolversMap.put(resolver.getName(), resolver);
if (resolver instanceof ChainResolver) {
List<DependencyResolver> subresolvers = ((ChainResolver) resolver).getResolvers();
for (DependencyResolver dr : subresolvers) {
addResolver(dr);
}
} else if (resolver instanceof DualResolver) {
DependencyResolver ivyResolver = ((DualResolver) resolver).getIvyResolver();
if (ivyResolver != null) {
addResolver(ivyResolver);
}
DependencyResolver artifactResolver = ((DualResolver) resolver).getArtifactResolver();
if (artifactResolver != null) {
addResolver(artifactResolver);
}
}
}
use of org.apache.ivy.plugins.resolver.DualResolver in project ant-ivy by apache.
the class ResolveTest method ivyTestCache.
/**
* Configures an Ivy instance using a resolver locating modules on file system, in a
* build/testCache2 location which is created for the test and removed after, and can thus
* easily simulate a repository availability problem
*
* @return the configured ivy instance
*/
private Ivy ivyTestCache() {
Ivy ivy = Ivy.newInstance();
DualResolver resolver = new DualResolver();
resolver.setName("dual");
FileSystemResolver r = new FileSystemResolver();
r.setName("1");
r.addIvyPattern(ivy.getSettings().getBaseDir().getPath() + "/build/testCache2/ivy-[module]-[revision].xml");
resolver.add(r);
r = new FileSystemResolver();
r.setName("2");
r.addArtifactPattern(ivy.getSettings().getBaseDir().getPath() + "/build/testCache2/[artifact]-[revision].[ext]");
resolver.add(r);
ivy.getSettings().addResolver(resolver);
ivy.getSettings().setDefaultResolver("dual");
return ivy;
}
use of org.apache.ivy.plugins.resolver.DualResolver in project ant-ivy by apache.
the class OBRResolverTest method setUp.
@Before
public void setUp() throws Exception {
settings = new IvySettings();
bundleResolver = new OBRResolver();
bundleResolver.setRepoXmlFile(new File("test/test-repo/bundlerepo/repo.xml").getAbsolutePath());
bundleResolver.setName("bundle");
bundleResolver.setSettings(settings);
settings.addResolver(bundleResolver);
bundleUrlResolver = new OBRResolver();
bundleUrlResolver.setRepoXmlURL(new File("test/test-repo/bundlerepo/repo.xml").toURI().toURL().toExternalForm());
bundleUrlResolver.setName("bundleurl");
bundleUrlResolver.setSettings(settings);
settings.addResolver(bundleUrlResolver);
dualResolver = new DualResolver();
OBRResolver resolver = new OBRResolver();
resolver.setRepoXmlFile(new File("test/test-repo/ivyrepo/repo.xml").getAbsolutePath());
resolver.setName("dual-bundle");
resolver.setSettings(settings);
dualResolver.add(resolver);
dualResolver.setName("dual");
File ivyrepo = new File("test/test-repo/ivyrepo");
FileSystemResolver fileSystemResolver = new FileSystemResolver();
fileSystemResolver.addIvyPattern(ivyrepo.getAbsolutePath() + "/[organisation]/[module]/[revision]/ivy.xml");
fileSystemResolver.addArtifactPattern(ivyrepo.getAbsolutePath() + "/[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]");
fileSystemResolver.setName("dual-file");
fileSystemResolver.setSettings(settings);
dualResolver.add(fileSystemResolver);
settings.addResolver(dualResolver);
settings.setDefaultResolver("bundle");
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.plugins.resolver.DualResolver in project ant-ivy by apache.
the class ResolveTest method testResolveDualChain.
@Test
public void testResolveDualChain() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(ResolveTest.class.getResource("dualchainresolverconf.xml"));
DependencyResolver resolver = ivy.getSettings().getResolver("default");
assertNotNull(resolver);
assertTrue(resolver instanceof DualResolver);
// first without cache
ivy.resolve(ResolveTest.class.getResource("ivy-dualchainresolver.xml"), getResolveOptions(new String[] { "default" }));
assertTrue(new File("build/cache/xerces/xerces/ivy-2.6.2.xml").exists());
assertTrue(new File("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists());
assertTrue(new File("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists());
// second with cache for ivy file only
new File("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").delete();
new File("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").delete();
assertFalse(new File("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists());
assertFalse(new File("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists());
ivy.resolve(ResolveTest.class.getResource("ivy-dualchainresolver.xml"), getResolveOptions(new String[] { "default" }));
assertTrue(new File("build/cache/xerces/xerces/ivy-2.6.2.xml").exists());
assertTrue(new File("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists());
assertTrue(new File("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists());
}
Aggregations