Search in sources :

Example 6 with RepositoryCacheManager

use of org.apache.ivy.core.cache.RepositoryCacheManager 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 7 with RepositoryCacheManager

use of org.apache.ivy.core.cache.RepositoryCacheManager in project ant-ivy by apache.

the class P2DescriptorTest method setUp.

@Before
public void setUp() throws Exception {
    settings = new IvySettings();
    p2SourceResolver = new UpdateSiteResolver();
    p2SourceResolver.setName("p2-sources");
    p2SourceResolver.setUrl(new File("test/test-p2/sources").toURI().toURL().toExternalForm());
    p2SourceResolver.setSettings(settings);
    settings.addResolver(p2SourceResolver);
    p2ZippedResolver = new UpdateSiteResolver();
    p2ZippedResolver.setName("p2-zipped");
    p2ZippedResolver.setUrl(new File("test/test-p2/zipped").toURI().toURL().toExternalForm());
    p2ZippedResolver.setSettings(settings);
    settings.addResolver(p2ZippedResolver);
    p2WithPackedResolver = new UpdateSiteResolver();
    p2WithPackedResolver.setName("p2-with-packed");
    p2WithPackedResolver.setUrl(new File("test/test-p2/packed").toURI().toURL().toExternalForm());
    p2WithPackedResolver.setSettings(settings);
    settings.addResolver(p2WithPackedResolver);
    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) IvySettings(org.apache.ivy.core.settings.IvySettings) UpdateSiteResolver(org.apache.ivy.osgi.updatesite.UpdateSiteResolver) File(java.io.File) Ivy(org.apache.ivy.Ivy) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 8 with RepositoryCacheManager

use of org.apache.ivy.core.cache.RepositoryCacheManager in project ant-ivy by apache.

the class UpdateSiteResolverTest method setUp.

@Before
public void setUp() throws Exception {
    settings = new IvySettings();
    resolver = new UpdateSiteResolver();
    resolver.setName("ivyde-repo");
    resolver.setUrl(new File("test/test-p2/ivyde-repo").toURI().toURL().toExternalForm());
    resolver.setSettings(settings);
    settings.addResolver(resolver);
    settings.setDefaultResolver("ivyde-repo");
    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) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Ivy(org.apache.ivy.Ivy) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 9 with RepositoryCacheManager

use of org.apache.ivy.core.cache.RepositoryCacheManager in project ant-ivy by apache.

the class AggregatedOSGiResolverTest method setUp.

@Before
public void setUp() throws Exception {
    settings = new IvySettings();
    OBRResolver bundleResolver = new OBRResolver();
    bundleResolver.setRepoXmlFile(new File("test/test-repo/bundlerepo/repo.xml").getAbsolutePath());
    bundleResolver.setName("bundle");
    bundleResolver.setSettings(settings);
    settings.addResolver(bundleResolver);
    UpdateSiteResolver updatesite = new UpdateSiteResolver();
    updatesite.setUrl(new File("test/test-p2/ivyde-repo").toURI().toURL().toExternalForm());
    updatesite.setName("updatesite");
    updatesite.setSettings(settings);
    settings.addResolver(updatesite);
    OBRResolver repo1 = new OBRResolver();
    repo1.setRepoXmlFile(new File("test/test-repo/multi-osgi/repo1/obr.xml").getAbsolutePath());
    repo1.setName("repo1");
    repo1.setSettings(settings);
    repo1.setRequirementStrategy(RequirementStrategy.noambiguity);
    settings.addResolver(repo1);
    OBRResolver repo2 = new OBRResolver();
    repo2.setRepoXmlFile(new File("test/test-repo/multi-osgi/repo2/obr.xml").getAbsolutePath());
    repo2.setName("repo2");
    repo2.setSettings(settings);
    repo2.setRequirementStrategy(RequirementStrategy.noambiguity);
    settings.addResolver(repo2);
    resolver = new AggregatedOSGiResolver();
    resolver.add(bundleResolver);
    resolver.add(updatesite);
    resolver.add(repo1);
    resolver.add(repo2);
    resolver.setName("multiosgi");
    resolver.setSettings(settings);
    settings.addResolver(resolver);
    settings.setDefaultResolver("multiosgi");
    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) OBRResolver(org.apache.ivy.osgi.obr.OBRResolver) IvySettings(org.apache.ivy.core.settings.IvySettings) UpdateSiteResolver(org.apache.ivy.osgi.updatesite.UpdateSiteResolver) File(java.io.File) AggregatedOSGiResolver(org.apache.ivy.osgi.repo.AggregatedOSGiResolver) Ivy(org.apache.ivy.Ivy) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 10 with RepositoryCacheManager

use of org.apache.ivy.core.cache.RepositoryCacheManager in project ant-ivy by apache.

the class UpdateSiteResolver method init.

protected void init() {
    if (url == null) {
        throw new RuntimeException("Missing url");
    }
    CacheResourceOptions options = new CacheResourceOptions();
    if (metadataTtl != null) {
        options.setTtl(metadataTtl);
    }
    if (forceMetadataUpdate != null) {
        options.setForce(forceMetadataUpdate);
    }
    final int log;
    if (logLevel != null) {
        if ("debug".equalsIgnoreCase(logLevel)) {
            log = Message.MSG_DEBUG;
        } else if ("verbose".equalsIgnoreCase(logLevel)) {
            log = Message.MSG_VERBOSE;
        } else if ("info".equalsIgnoreCase(logLevel)) {
            log = Message.MSG_INFO;
        } else if ("warn".equalsIgnoreCase(logLevel)) {
            log = Message.MSG_WARN;
        } else if ("error".equalsIgnoreCase(logLevel)) {
            log = Message.MSG_ERR;
        } else {
            throw new RuntimeException("Unknown log level: " + logLevel);
        }
    } else {
        log = Message.MSG_INFO;
    }
    options.setListener(new DownloadListener() {

        public void startArtifactDownload(RepositoryCacheManager cache, ResolvedResource rres, Artifact artifact, ArtifactOrigin origin) {
            if (log <= Message.MSG_INFO) {
                Message.info("\tdownloading " + rres.getResource().getName());
            }
        }

        public void needArtifact(RepositoryCacheManager cache, Artifact artifact) {
            if (log <= Message.MSG_VERBOSE) {
                Message.verbose("\ttrying to download " + artifact);
            }
        }

        public void endArtifactDownload(RepositoryCacheManager cache, Artifact artifact, ArtifactDownloadReport adr, File archiveFile) {
            if (log <= Message.MSG_VERBOSE) {
                if (adr.isDownloaded()) {
                    Message.verbose("\tdownloaded to " + archiveFile.getAbsolutePath());
                } else {
                    Message.verbose("\tnothing to download");
                }
            }
        }
    });
    final UpdateSiteLoader loader = new UpdateSiteLoader(getRepositoryCacheManager(), getEventManager(), options, this.getTimeoutConstraint());
    loader.setLogLevel(log);
    RepoDescriptor repoDescriptor;
    try {
        repoDescriptor = loader.load(new URI(url));
    } catch (IOException e) {
        throw new RuntimeException("IO issue while trying to read the update site (" + e.getMessage() + ")");
    } catch (ParseException e) {
        throw new RuntimeException("Failed to parse the updatesite (" + e.getMessage() + ")", e);
    } catch (SAXException e) {
        throw new RuntimeException("Ill-formed updatesite (" + e.getMessage() + ")", e);
    } catch (URISyntaxException e) {
        throw new RuntimeException("Ill-formed url (" + e.getMessage() + ")", e);
    }
    if (repoDescriptor == null) {
        setRepoDescriptor(FAILING_REPO_DESCRIPTOR);
        throw new RuntimeException("No update site was found at the location: " + url);
    }
    setRepoDescriptor(repoDescriptor);
}
Also used : RepositoryCacheManager(org.apache.ivy.core.cache.RepositoryCacheManager) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) ArtifactOrigin(org.apache.ivy.core.cache.ArtifactOrigin) URI(java.net.URI) Artifact(org.apache.ivy.core.module.descriptor.Artifact) SAXException(org.xml.sax.SAXException) ResolvedResource(org.apache.ivy.plugins.resolver.util.ResolvedResource) DownloadListener(org.apache.ivy.core.cache.DownloadListener) RepoDescriptor(org.apache.ivy.osgi.repo.RepoDescriptor) CacheResourceOptions(org.apache.ivy.core.cache.CacheResourceOptions) ParseException(java.text.ParseException) File(java.io.File)

Aggregations

RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)12 File (java.io.File)8 Ivy (org.apache.ivy.Ivy)6 IvySettings (org.apache.ivy.core.settings.IvySettings)6 ResolveData (org.apache.ivy.core.resolve.ResolveData)5 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)5 Before (org.junit.Before)5 IOException (java.io.IOException)4 ParseException (java.text.ParseException)3 Artifact (org.apache.ivy.core.module.descriptor.Artifact)3 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)3 SAXException (org.xml.sax.SAXException)3 FileOutputStream (java.io.FileOutputStream)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)2 UpdateSiteResolver (org.apache.ivy.osgi.updatesite.UpdateSiteResolver)2 ResolvedResource (org.apache.ivy.plugins.resolver.util.ResolvedResource)2 BuildException (org.apache.tools.ant.BuildException)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1