Package org.apache.ivy.core.cache

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


        pattern = getProperty(pattern, getSettings(), "ivy.retrieve.pattern");

        try {
            String[] confs = splitConfs(getConf());
            CacheManager cacheManager = CacheManager.getInstance(getSettings(), getCache());
            ModuleDescriptor md = null;
            if (getResolveId() != null) {
                md = (ModuleDescriptor) getResolvedDescriptor(getResolveId());
            } else {
                md = (ModuleDescriptor) getResolvedDescriptor(getOrganisation(), getModule()
View Full Code Here


     * Default implementation actually download the artifact Subclasses should overwrite this to
     * avoid the download
     */
    public boolean exists(Artifact artifact) {
        DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions(getSettings(),
                new CacheManager(getSettings(), getSettings().getDefaultCache()), null, true));
        ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
        return adr.getDownloadStatus() != DownloadStatus.FAILED;
    }
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

            String mainclass, String[] args) {
        List urls = new ArrayList();

        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

    public void doExecute() throws BuildException {
        prepareAndCheck();

        try {
            CacheManager cacheMgr = getIvyInstance().getCacheManager(getCache());
            String[] confs = splitConfs(getConf());
            String resolveId = getResolveId();
            if (resolveId == null) {
                resolveId = ResolveOptions.getDefaultResolveId(getResolvedModuleId());
            }
            XmlReportParser parser = new XmlReportParser();
            for (int i = 0; i < confs.length; i++) {
                File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
                parser.parse(report);

                Artifact[] artifacts = parser.getArtifacts();
                for (int j = 0; j < artifacts.length; j++) {
                    Artifact artifact = artifacts[j];
View Full Code Here

            String resolveId = ResolveOptions.getDefaultResolveId(md);
            ResolveReport report = ivy.resolve(md, new ResolveOptions().setResolveId(resolveId)
                    .setCache(CacheManager.getInstance(settings, cache)).setValidate(
                        doValidate(settings)));

            CacheManager cacheMgr = getIvyInstance().getCacheManager(cache);
            new XmlReportOutputter().output(report, cache);
            if (graph) {
                gengraph(cacheMgr, md.getModuleRevisionId().getOrganisation(), md
                        .getModuleRevisionId().getName());
            }
            if (dot) {
                gendot(cacheMgr, md.getModuleRevisionId().getOrganisation(), md
                        .getModuleRevisionId().getName());
            }
            if (xml) {

                FileUtil.copy(cacheMgr.getConfigurationResolveReportInCache(resolveId, "default"),
                    new File(todir, outputname + ".xml"), null);
            }
            if (xsl) {
                genreport(cacheMgr, md.getModuleRevisionId().getOrganisation(), md
                        .getModuleRevisionId().getName());
View Full Code Here

    private EventManager eventManager = null; // can be null

    private boolean useOrigin = false;

    public DownloadOptions(IvySettings settings, File cache) {
        this(settings, new CacheManager(settings, cache));
    }
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().setCache(cacheManager.getCache());
            }

            String[] confs = options.getConfs();
            if (confs.length == 1 && confs[0].equals("*")) {
                confs = md.getConfigurationsNames();
            }
            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++) {
                    if (!dependencies[i].isCompletelyEvicted() && !dependencies[i].hasProblem()) {
                        DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
                        if (dd != null) {
                            String rev = dependencies[i].getResolvedId().getRevision();
                            String status = dependencies[i].getDescriptor().getStatus();
                            props.put(dd.getDependencyRevisionId().encodeToString(), rev + " "
                                    + status);
                        }
                    }
                }
            }
            FileOutputStream out = new FileOutputStream(ivyPropertiesInCache);
            props.store(out, md.getResolvedModuleRevisionId() + " resolved revisions");
            out.close();
            Message.verbose("\tresolved ivy file produced in " + ivyFileInCache);

            report.setResolveTime(System.currentTimeMillis() - start);

            if (options.isDownload()) {
                Message.verbose(":: downloading artifacts ::");

                downloadArtifacts(report, cacheManager, options.isUseOrigin(), options
                        .getArtifactFilter());
            }

            if (options.isOutputReport()) {
                outputReport(report, cacheManager.getCache());
            }

            eventManager.fireIvyEvent(new EndResolveEvent(md, confs, report));
            return report;
        } finally {
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();
        if (cacheManager == null) { // ensure that a cache is configured
            cacheManager = IvyContext.getContext().getCacheManager();
            options.setCache(cacheManager);
        } else {
            IvyContext.getContext().setCache(cacheManager.getCache());
        }

        String[] confs = options.getConfs();
        if (confs.length == 1 && confs[0].equals("*")) {
            confs = md.getConfigurationsNames();
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.