~ubuntu-branches/ubuntu/trusty/ivy/trusty-proposed

« back to all changes in this revision

Viewing changes to src/java/org/apache/ivy/core/resolve/ResolveEngine.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-15 17:44:57 UTC
  • mfrom: (3.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130515174457-ogntd0vxluwalq11
Tags: 2.3.0-2
* Team upload.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
53
53
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
54
54
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 
55
import org.apache.ivy.core.module.id.ModuleId;
55
56
import org.apache.ivy.core.module.id.ModuleRevisionId;
56
57
import org.apache.ivy.core.report.ArtifactDownloadReport;
57
58
import org.apache.ivy.core.report.ConfigurationResolveReport;
65
66
import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
66
67
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
67
68
import org.apache.ivy.plugins.repository.url.URLResource;
68
 
import org.apache.ivy.plugins.resolver.CacheResolver;
69
69
import org.apache.ivy.plugins.resolver.DependencyResolver;
70
70
import org.apache.ivy.plugins.version.VersionMatcher;
71
71
import org.apache.ivy.util.Message;
202
202
            throws ParseException, IOException {
203
203
        DependencyResolver oldDictator = getDictatorResolver();
204
204
        IvyContext context = IvyContext.getContext();
205
 
        if (options.isUseCacheOnly()) {
206
 
            setDictatorResolver(new CacheResolver(settings));
207
 
        }
208
205
        try {
209
206
            String[] confs = options.getConfs(md);
210
207
            options.setConfs(confs);
243
240
 
244
241
            // produce resolved ivy file and ivy properties in cache
245
242
            ResolutionCacheManager cacheManager = settings.getResolutionCacheManager();
246
 
            File ivyFileInCache = cacheManager.getResolvedIvyFileInCache(md
247
 
                    .getResolvedModuleRevisionId());
248
 
            md.toIvyFile(ivyFileInCache);
 
243
            cacheManager.saveResolvedModuleDescriptor(md);
249
244
 
250
245
            // we store the resolved dependencies revisions and statuses per asked dependency
251
 
            // revision id,
252
 
            // for direct dependencies only.
 
246
            // revision id, for direct dependencies only.
253
247
            // this is used by the deliver task to resolve dynamic revisions to static ones
254
248
            File ivyPropertiesInCache = cacheManager.getResolvedIvyPropertiesInCache(
255
249
                        md.getResolvedModuleRevisionId());
262
256
                        forcedRevisions.put(dependencies[i].getModuleId(), dependencies[i].getResolvedId());
263
257
                    }
264
258
                }
265
 
 
 
259
                
266
260
                IvyNode root = dependencies[0].getRoot();
 
261
 
 
262
                //                <ModuleId,IvyNode>();
 
263
                Map topLevelDeps = new HashMap(); //
267
264
                for (int i = 0; i < dependencies.length; i++) {
268
265
                    if (!dependencies[i].hasProblem()) {
269
266
                        DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
270
267
                        if (dd != null) {
 
268
                            ModuleId orgMod = dependencies[i].getModuleId();
 
269
                            topLevelDeps.put(orgMod, dependencies[i]);
 
270
                        }
 
271
                    }
 
272
                }
 
273
 
 
274
                for (int i = 0; i < dependencies.length; i++) {
 
275
                    if (!dependencies[i].hasProblem() && !dependencies[i].isCompletelyEvicted()) {
 
276
                        DependencyDescriptor dd = dependencies[i].getDependencyDescriptor(root);
 
277
                        if (dd == null) {
 
278
                            ModuleId mid = dependencies[i].getModuleId();
 
279
                            IvyNode tlDep = (IvyNode)topLevelDeps.get(mid);
 
280
                            if (tlDep != null) {
 
281
                                dd = tlDep.getDependencyDescriptor(root);
 
282
                            }
 
283
                        }
 
284
                        if (dd != null) {
271
285
                            ModuleRevisionId depResolvedId = dependencies[i].getResolvedId();
272
286
                            ModuleDescriptor depDescriptor = dependencies[i].getDescriptor();
273
287
                            ModuleRevisionId depRevisionId = dd.getDependencyRevisionId();
298
312
                            
299
313
                            // The evicted modules have no description, so we can't put the status
300
314
                            String status = depDescriptor == null ? "?" : depDescriptor.getStatus();
301
 
                            props.put(depRevisionId.encodeToString(), rev + " " + status + " " + forcedRev);
 
315
                            Message.debug("storing dependency " + depResolvedId + " in props");
 
316
                            props.put(depRevisionId.encodeToString(), rev + " " + status + " " + forcedRev + " " + depResolvedId.getBranch());
302
317
                        }
303
318
                    }
304
319
                }
306
321
            FileOutputStream out = new FileOutputStream(ivyPropertiesInCache);
307
322
            props.store(out, md.getResolvedModuleRevisionId() + " resolved revisions");
308
323
            out.close();
309
 
            Message.verbose("\tresolved ivy file produced in " + ivyFileInCache);
 
324
            Message.verbose("\tresolved ivy file produced in cache");
310
325
 
311
326
            report.setResolveTime(System.currentTimeMillis() - start);
312
327
 
498
513
 
499
514
    /**
500
515
     * Resolve the dependencies of a module without downloading corresponding artifacts. The module
501
 
     * to resolve is given by its module descriptor.This method requires appropriate configuration
 
516
     * to resolve is given by its module descriptor. This method requires appropriate configuration
502
517
     * of the ivy instance, especially resolvers.
 
518
     * <p>
 
519
     * The <code>IvyNode</code>s are ordered from the most dependent to the less dependent, so that
 
520
     * an IvyNode is always found in the list after all IvyNode depending directly on it.
503
521
     * 
504
522
     * @param md
505
523
     *            the descriptor of the module for which we want to get dependencies - must not be
771
789
 
772
790
        // now we can actually resolve this configuration dependencies
773
791
        if (!isDependenciesFetched(node.getNode(), conf) && node.isTransitive()) {
774
 
            Collection dependencies = node.getDependencies(conf);
 
792
            Collection/*<VisitNode>*/ dependencies = node.getDependencies(conf);
775
793
            for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
776
794
                VisitNode dep = (VisitNode) iter.next();
777
795
                dep.useRealNode(); // the node may have been resolved to another real one while
1048
1066
        /*
1049
1067
         * We first try to remove all evicted nodes from the collection of selected nodes to update
1050
1068
         * this collection. If the collection changes, it means that it contained evicted nodes, and
1051
 
         * thus is not up to date. In this case we need to compute selected nodes again. Another
1052
 
         * case where we need to deeply compute selected nodes is when selectedNodes is empty (not
1053
 
         * computed yet) and we aren't in the context of the direct parent of the node.
1054
 
         */
1055
 
        if (selectedNodes.removeAll(toevict) 
1056
 
                || (selectedNodes.isEmpty() 
 
1069
         * thus is not up to date.
 
1070
         */
 
1071
        boolean evictedInSelected = selectedNodes.removeAll(toevict);
 
1072
        /*
 
1073
         * Another case where we need to deeply compute selected nodes is when selectedNodes is
 
1074
         * empty (not computed yet) and we aren't in the context of the direct parent of the node.
 
1075
         */
 
1076
        if (evictedInSelected || (selectedNodes.isEmpty() 
1057
1077
                        && !node.getParent().getNode().equals(ancestor.getNode()))) {
 
1078
            // In this case we need to compute selected nodes again. 
1058
1079
            Collection deps = ancestor.getNode().getDependencies(
1059
1080
                node.getRootModuleConf(), 
1060
 
                ancestor.getNode().getConfigurations(node.getRootModuleConf()));
 
1081
                ancestor.getNode().getConfigurations(node.getRootModuleConf()), 
 
1082
                ancestor.getRequestedConf());
1061
1083
            for (Iterator iter = deps.iterator(); iter.hasNext();) {
1062
1084
                IvyNode dep = (IvyNode) iter.next();
1063
1085
                if (dep.getModuleId().equals(node.getModuleId())) {
1072
1094
             * (otherwise previous block would have been reached). We can compute conflicts based on
1073
1095
             * the parent direct dependencies in current root module conf.
1074
1096
             */
1075
 
            Collection parentDepIvyNodes = node.getParent().getNode()
1076
 
                        .getDependencies(node.getRootModuleConf(), 
1077
 
                            new String[] {node.getParentConf()});
 
1097
            VisitNode parent = node.getParent();
 
1098
            Collection parentDepIvyNodes = parent.getNode().getDependencies(
 
1099
                node.getRootModuleConf(), 
 
1100
                parent.getNode().getConfigurations(node.getRootModuleConf()), 
 
1101
                parent.getRequestedConf());
1078
1102
            for (Iterator it = parentDepIvyNodes.iterator(); it.hasNext();) {
1079
1103
                IvyNode parentDep = (IvyNode) it.next();
1080
1104
                if (parentDep.getModuleId().equals(node.getModuleId())) {