Search in sources :

Example 1 with DualResolver

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);
        }
    }
}
Also used : WorkspaceChainResolver(org.apache.ivy.plugins.resolver.WorkspaceChainResolver) ChainResolver(org.apache.ivy.plugins.resolver.ChainResolver) DualResolver(org.apache.ivy.plugins.resolver.DualResolver) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

Example 2 with DualResolver

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;
}
Also used : DualResolver(org.apache.ivy.plugins.resolver.DualResolver) Ivy(org.apache.ivy.Ivy) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver)

Example 3 with DualResolver

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());
}
Also used : ResolveData(org.apache.ivy.core.resolve.ResolveData) RepositoryCacheManager(org.apache.ivy.core.cache.RepositoryCacheManager) DualResolver(org.apache.ivy.plugins.resolver.DualResolver) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Ivy(org.apache.ivy.Ivy) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Before(org.junit.Before)

Example 4 with DualResolver

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());
}
Also used : DualResolver(org.apache.ivy.plugins.resolver.DualResolver) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver) Test(org.junit.Test)

Aggregations

DualResolver (org.apache.ivy.plugins.resolver.DualResolver)4 Ivy (org.apache.ivy.Ivy)3 File (java.io.File)2 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)2 FileSystemResolver (org.apache.ivy.plugins.resolver.FileSystemResolver)2 JarFile (java.util.jar.JarFile)1 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)1 ResolveData (org.apache.ivy.core.resolve.ResolveData)1 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)1 IvySettings (org.apache.ivy.core.settings.IvySettings)1 ChainResolver (org.apache.ivy.plugins.resolver.ChainResolver)1 WorkspaceChainResolver (org.apache.ivy.plugins.resolver.WorkspaceChainResolver)1 Before (org.junit.Before)1 Test (org.junit.Test)1