Package org.apache.ivy.core.cache

Examples of org.apache.ivy.core.cache.CacheManager


    public void setCacheManager(CacheManager cacheManager) {
        this.cacheManager = cacheManager;
    }

    public CacheManager getCacheManager() {
        CacheManager result = cacheManager;
        if (result == null) {
            result = CacheManager.getInstance(getSettings());
        }
        return result;
    }
View Full Code Here


        DependencyResolver oldDictator = getDictatorResolver();
        if (options.isUseCacheOnly()) {
            setDictatorResolver(new CacheResolver(settings));
        }
        try {
            CacheManager cacheManager = options.getCache();
            if (cacheManager == null) { // ensure that a cache is configured
                cacheManager = IvyContext.getContext().getCacheManager();
                options.setCache(cacheManager);
            } else {
                IvyContext.getContext().setCacheManager(cacheManager);
            }

            String[] confs = options.getConfs(md);
            options.setConfs(confs);

            if (options.getResolveId() == null) {
                options.setResolveId(ResolveOptions.getDefaultResolveId(md));
            }

            eventManager.fireIvyEvent(new StartResolveEvent(md, confs));

            long start = System.currentTimeMillis();
            Message.info(":: resolving dependencies :: " + md.getResolvedModuleRevisionId()
                    + (options.isTransitive() ? "" : " [not transitive]"));
            Message.info("\tconfs: " + Arrays.asList(confs));
            Message.verbose("\tvalidate = " + options.isValidate());
            ResolveReport report = new ResolveReport(md, options.getResolveId());

            // resolve dependencies
            IvyNode[] dependencies = getDependencies(md, options, report);
            report.setDependencies(Arrays.asList(dependencies), options.getArtifactFilter());

            // produce resolved ivy file and ivy properties in cache
            File ivyFileInCache = cacheManager.getResolvedIvyFileInCache(md
                    .getResolvedModuleRevisionId());
            md.toIvyFile(ivyFileInCache);

            // we store the resolved dependencies revisions and statuses per asked dependency
            // revision id,
            // for direct dependencies only.
            // this is used by the deliver task to resolve dynamic revisions to static ones
            File ivyPropertiesInCache = cacheManager.getResolvedIvyPropertiesInCache(
                        md.getResolvedModuleRevisionId());
            Properties props = new Properties();
            if (dependencies.length > 0) {
                IvyNode root = dependencies[0].getRoot();
                for (int i = 0; i < dependencies.length; i++) {
View Full Code Here

    public IvyNode[] getDependencies(ModuleDescriptor md, ResolveOptions options,
            ResolveReport report) {
        if (md == null) {
            throw new NullPointerException("module descriptor must not be null");
        }
        CacheManager cacheManager = options.getCache();
        IvyContext context = IvyContext.getContext();
        if (cacheManager == null) { // ensure that a cache is configured
            cacheManager = context.getCacheManager();
            options.setCache(cacheManager);
        } else {
View Full Code Here

        }
        return confs;
    }

    private CacheManager getCacheManager(RetrieveOptions options) {
        CacheManager cacheManager = options.getCache();
        if (cacheManager == null) { // ensure that a cache is configured
            cacheManager = IvyContext.getContext().getCacheManager();
            options.setCache(cacheManager);
        } else {
            IvyContext.getContext().setCacheManager(cacheManager);
View Full Code Here

        return resolver.getDependency(
            new DefaultDependencyDescriptor(ModuleRevisionId.parse(module), false),
            new ResolveData(
                new ResolveEngine(settings, new EventManager(), new SortEngine(settings)),
                new ResolveOptions().setCache(
                    new CacheManager(settings, new File("build/test/publish/cache")))));
    }
View Full Code Here

            if (!cache.exists()) {
                cache.mkdirs();
            } else if (!cache.isDirectory()) {
                error(options, cache + " is not a directory");
            }
            CacheManager cacheManager = CacheManager.getInstance(settings, cache);

            String[] confs;
            if (line.hasOption("confs")) {
                confs = line.getOptionValues("confs");
            } else {
View Full Code Here

            String outFile) {
        try {
            String pathSeparator = System.getProperty("path.separator");
            StringBuffer buf = new StringBuffer();
            Collection all = new LinkedHashSet();
            CacheManager cacheMgr = ivy.getCacheManager(cache);
            XmlReportParser parser = new XmlReportParser();
            for (int i = 0; i < confs.length; i++) {
                String resolveId = ResolveOptions.getDefaultResolveId(md);
                File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
                parser.parse(report);

                Artifact[] artifacts = parser.getArtifacts();
                all.addAll(Arrays.asList(artifacts));
            }
View Full Code Here

            }
        }
       
        try {
            Collection all = new LinkedHashSet();
            CacheManager cacheMgr = ivy.getCacheManager(cache);
            XmlReportParser parser = new XmlReportParser();
            for (int i = 0; i < confs.length; i++) {
                String resolveId = ResolveOptions.getDefaultResolveId(md);
                File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
                parser.parse(report);

                Artifact[] artifacts = parser.getArtifacts();
                all.addAll(Arrays.asList(artifacts));
            }
            for (Iterator iter = all.iterator(); iter.hasNext();) {
                Artifact artifact = (Artifact) iter.next();

                urls.add(cacheMgr.getArchiveFileInCache(artifact).toURL());
            }
        } catch (Exception ex) {
            throw new RuntimeException(
                "impossible to build ivy cache path: " + ex.getMessage(), ex);
        }
View Full Code Here

        engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
        cache = new File("build/cache");
        data = new ResolveData(engine, new ResolveOptions().setCache(CacheManager.getInstance(
            settings, cache)));
        cache.mkdirs();
        cacheManager = new CacheManager(settings, cache);
        settings.setDefaultCache(cache);
    }
View Full Code Here

        assertEquals(pubdate, rmr.getPublicationDate());

        // test to ask to download
        DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar");
        DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions(
                new CacheManager(_settings, _cache), true));
        assertNotNull(report);

        assertEquals(1, report.getArtifactsReports().length);

        ArtifactDownloadReport ar = report.getArtifactReport(artifact);
View Full Code Here

TOP

Related Classes of org.apache.ivy.core.cache.CacheManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.