Package org.apache.ivy.core.cache

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


        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(
                _settings, new CacheManager(_settings, _cache), null, true));
        assertNotNull(report);

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

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


        }
    }

    private CacheManager getCacheManager(File cache) {
        // TODO : reuse instance
        CacheManager cacheManager = new CacheManager(settings, cache);
        return cacheManager;
    }
View Full Code Here

                ModuleRevisionId revId = ModuleRevisionId.newInstance(org, moduleName, branch,
                    revision);
                Artifact artifact = new DefaultArtifact(revId, null, artifactName, artifactType,
                        artifactExt);

                CacheManager cacheManager = IvyContext.getContext().getCacheManager();

                origin = cacheManager.getSavedArtifactOrigin(artifact);

                if (origin == null) {
                    Message.debug("no artifact origin found for " + artifact + " in "
                            + cacheManager);
                    return null;
View Full Code Here

            if (!ivyFile.exists()) {
                throw new IllegalArgumentException("ivy file to publish not found for " + mrid
                        + ": call deliver before (" + ivyFile + ")");
            }
        } else {
            CacheManager cacheManager = getCacheManager(options);
            ivyFile = cacheManager.getResolvedIvyFileInCache(mrid);
            if (!ivyFile.exists()) {
                throw new IllegalStateException("ivy file not found in cache for " + mrid
                        + ": please resolve dependencies before publishing (" + ivyFile + ")");
            }
        }
View Full Code Here

            return false;
        }
    }

    private CacheManager getCacheManager(PublishOptions options) {
        CacheManager cacheManager = options.getCache();
        if (cacheManager == null) { // ensure that a cache is configured
            cacheManager = IvyContext.getContext().getCacheManager();
            options.setCache(cacheManager);
        } else {
            IvyContext.getContext().setCache(cacheManager.getCache());
        }
        return cacheManager;
    }
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

        destFilePattern = IvyPatternHelper.substituteVariables(destFilePattern, settings
                .getVariables());
        String destIvyPattern = IvyPatternHelper.substituteVariables(options.getDestIvyPattern(),
            settings.getVariables());

        CacheManager cacheManager = getCacheManager(options);
        String[] confs = getConfs(mrid, options);
        Message.info("\tconfs: " + Arrays.asList(confs));

        try {
            Map artifactsToCopy = determineArtifactsToCopy(mrid, destFilePattern, options);
            File fileRetrieveRoot = new File(IvyPatternHelper.getTokenRoot(destFilePattern));
            File ivyRetrieveRoot = destIvyPattern == null ? null : new File(IvyPatternHelper
                    .getTokenRoot(destIvyPattern));
            Collection targetArtifactsStructure = new HashSet(); // Set(File) set of all paths
            // which should be present at
            // then end of retrieve (useful
            // for sync)
            Collection targetIvysStructure = new HashSet(); // same for ivy files

            // do retrieve
            int targetsCopied = 0;
            int targetsUpToDate = 0;
            for (Iterator iter = artifactsToCopy.keySet().iterator(); iter.hasNext();) {
                Artifact artifact = (Artifact) iter.next();
                File archive;
                if ("ivy".equals(artifact.getType())) {
                    archive = cacheManager.getIvyFileInCache(artifact.getModuleRevisionId());
                } else {
                    archive = cacheManager.getArchiveFileInCache(artifact, cacheManager
                            .getSavedArtifactOrigin(artifact), options.isUseOrigin());
                    if (!options.isUseOrigin() && !archive.exists()) {
                        // file is not available in cache, maybe the last resolve was performed with
                        // useOrigin=true.
                        // we try to use the best we can
                        archive = cacheManager.getArchiveFileInCache(artifact, cacheManager
                                .getSavedArtifactOrigin(artifact));
                    }
                }
                Set dest = (Set) artifactsToCopy.get(artifact);
                Message.verbose("\tretrieving " + archive);
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().setCache(cacheManager.getCache());
        }
        return cacheManager;
    }
View Full Code Here

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

        CacheManager cacheManager = getCacheManager(options);
        String[] confs = getConfs(mrid, options);
        String destIvyPattern = IvyPatternHelper.substituteVariables(options.getDestIvyPattern(),
            settings.getVariables());

        // find what we must retrieve where
        final Map artifactsToCopy = new HashMap(); // Artifact source -> Set (String
        // copyDestAbsolutePath)
        final Map conflictsMap = new HashMap(); // String copyDestAbsolutePath -> Set (Artifact
        // source)
        final Map conflictsConfMap = new HashMap(); // String copyDestAbsolutePath -> Set (String
        // conf)
        XmlReportParser parser = new XmlReportParser();
        for (int i = 0; i < confs.length; i++) {
            final String conf = confs[i];

            File report = cacheManager.getConfigurationResolveReportInCache(options.getResolveId(),
                conf);
            parser.parse(report);

            Collection artifacts = new ArrayList(Arrays.asList(parser.getArtifacts()));
            if (destIvyPattern != null) {
View Full Code Here

        this.md = md;
        this.conf = conf;
        this.date = date;

        // parse previous deps from previous report file if any
        CacheManager cache = options.getCache();
        String resolveId = options.getResolveId();
        File previousReportFile = cache.getConfigurationResolveReportInCache(resolveId, conf);
        if (previousReportFile.exists()) {
            try {
                XmlReportParser parser = new XmlReportParser();
                parser.parse(previousReportFile);
                previousDeps = Arrays.asList(parser.getDependencyRevisionIds());
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.