Package org.apache.ivy.core.cache

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


        long start = System.currentTimeMillis();
       
        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);
                for (Iterator it2 = dest.iterator(); it2.hasNext();) {
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) {
                ModuleRevisionId[] mrids = parser.getRealDependencyRevisionIds();
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

    private static void outputCachePath(Ivy ivy, File cache, ModuleDescriptor md, String[] confs, 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

    private static void invoke(Ivy ivy, File cache, ModuleDescriptor md, String[] confs, 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 String toString() {
      if (origin == null) {
          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

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

          ivyFile = new File(IvyPatternHelper.substitute(options.getSrcIvyPattern(), DefaultArtifact.newIvyArtifact(pubmrid, new Date())));
          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

        }
    }


  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

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.