You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2011/04/28 23:39:46 UTC

svn commit: r1097621 - in /ant/ivy/core/trunk/src/java/org/apache/ivy: core/module/descriptor/DefaultDependencyDescriptor.java core/resolve/IvyNode.java core/resolve/ResolveEngine.java core/resolve/VisitNode.java util/extendable/ExtendableItemHelper.java

Author: hibou
Date: Thu Apr 28 21:39:46 2011
New Revision: 1097621

URL: http://svn.apache.org/viewvc?rev=1097621&view=rev
Log:
* add some comment and javadoc
* make the call of resolveSpecialConfigurations on the IvyNode rather than putting it in paramater

Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java?rev=1097621&r1=1097620&r2=1097621&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java Thu Apr 28 21:39:46 2011
@@ -245,13 +245,14 @@ public class DefaultDependencyDescriptor
 
     /**
      * Return the dependency configurations mapped to the given moduleConfiguration, actually
-     * resolved because of the given requestedConfiguration Usually requestedConfiguration and
-     * moduleConfiguration are the same, except when a conf extends another, then the
-     * moduleConfiguration is the configuration currently resolved (the extended one), and
-     * requestedConfiguration is the one actually requested initially (the extending one). Both
-     * moduleConfiguration and requestedConfiguration are configurations of the caller, the array
-     * returned is composed of the required configurations of the dependency described by this
-     * descriptor.
+     * resolved because of the given requestedConfiguration
+     * <p>
+     * Usually requestedConfiguration and moduleConfiguration are the same, except when a conf
+     * extends another, then the moduleConfiguration is the configuration currently resolved (the
+     * extended one), and requestedConfiguration is the one actually requested initially (the
+     * extending one). Both moduleConfiguration and requestedConfiguration are configurations of the
+     * caller, the array returned is composed of the required configurations of the dependency
+     * described by this descriptor.
      */
     public String[] getDependencyConfigurations(String moduleConfiguration,
             String requestedConfiguration) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java?rev=1097621&r1=1097620&r2=1097621&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java Thu Apr 28 21:39:46 2011
@@ -229,8 +229,9 @@ public class IvyNode implements Comparab
                         
                         md = module.getDescriptor();
                         confsToFetch.remove("*");
-                        updateConfsToFetch(Arrays.asList(resolveSpecialConfigurations(
-                            getRequiredConfigurations(parent, parentConf), this)));
+                        updateConfsToFetch(Arrays
+                                .asList(resolveSpecialConfigurations(getRequiredConfigurations(
+                                    parent, parentConf))));
                     } else {
                         Message.warn("\tmodule not found: " + getId());
                         resolver.reportFailure();
@@ -306,13 +307,26 @@ public class IvyNode implements Comparab
         return deps;
     }
 
-    public Collection getDependencies(String rootModuleConf, String conf, String requestedConf) {
+    /**
+     * Load the dependencies of the current node
+     * <p>
+     * The resulting collection of nodes may have some configuration to load
+     * 
+     * @param rootModuleConf
+     *            the requested configuration of the root module
+     * @param conf
+     *            the configuration to load of this node
+     * @param requestedConf
+     *            the actual node conf requested, possibly extending the <code>conf</code> one.
+     * @return
+     */
+    public Collection/*<IvyNode>*/ getDependencies(String rootModuleConf, String conf, String requestedConf) {
         if (md == null) {
             throw new IllegalStateException(
                     "impossible to get dependencies when data has not been loaded");
         }
         DependencyDescriptor[] dds = md.getDependencies();
-        Map dependencies = new LinkedHashMap(); // it's important to respect order
+        Map/*<ModuleRevisionId, IvyNode> */ dependencies = new LinkedHashMap(); // it's important to respect order
         for (int i = 0; i < dds.length; i++) {
             DependencyDescriptor dd = data.mediate(dds[i]);
             String[] dependencyConfigurations = dd.getDependencyConfigurations(conf, requestedConf);
@@ -329,8 +343,10 @@ public class IvyNode implements Comparab
                 continue;
             }
 
+            // check if not already loaded here
             IvyNode depNode = (IvyNode) dependencies.get(requestedDependencyRevisionId);
             if (depNode == null) {
+                // check if not already loaded during the resolve session
                 depNode = data.getNode(requestedDependencyRevisionId);
             }
 
@@ -344,8 +360,7 @@ public class IvyNode implements Comparab
                 }
 
             }
-            String[] confsArray = resolveSpecialConfigurations(dependencyConfigurations,
-                depNode);
+            String[] confsArray = depNode.resolveSpecialConfigurations(dependencyConfigurations);
             Collection confs = Arrays.asList(confsArray);
             depNode.updateConfsToFetch(confs);
             depNode.addRootModuleConfigurations(depNode.usage, rootModuleConf, confsArray);
@@ -455,18 +470,17 @@ public class IvyNode implements Comparab
     /**
      * resolve the '*' special configurations if necessary and possible
      */
-    private String[] resolveSpecialConfigurations(String[] dependencyConfigurations, IvyNode node) {
+    private String[] resolveSpecialConfigurations(String[] dependencyConfigurations) {
         if (dependencyConfigurations.length == 1 && dependencyConfigurations[0].startsWith("*")
-                && node != null && node.isLoaded()) {
+                && isLoaded()) {
             String conf = dependencyConfigurations[0];
             if ("*".equals(conf)) {
-                return node.getDescriptor().getPublicConfigurationsNames();
+                return getDescriptor().getPublicConfigurationsNames();
             }
             // there are exclusions in the configuration
             List exclusions = Arrays.asList(conf.substring(2).split("\\!"));
 
-            List ret = new ArrayList(Arrays.asList(node.getDescriptor()
-                    .getPublicConfigurationsNames()));
+            List ret = new ArrayList(Arrays.asList(getDescriptor().getPublicConfigurationsNames()));
             ret.removeAll(exclusions);
 
             return (String[]) ret.toArray(new String[ret.size()]);
@@ -627,7 +641,7 @@ public class IvyNode implements Comparab
             conf = defaultConf;
         }
         if (conf.startsWith("*")) {
-            return resolveSpecialConfigurations(new String[] {conf}, this);
+            return resolveSpecialConfigurations(new String[] {conf});
         } else if (conf.indexOf(',') != -1) {
             String[] confs = conf.split(",");
             for (int i = 0; i < confs.length; i++) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java?rev=1097621&r1=1097620&r2=1097621&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java Thu Apr 28 21:39:46 2011
@@ -1045,13 +1045,16 @@ public class ResolveEngine {
         /*
          * We first try to remove all evicted nodes from the collection of selected nodes to update
          * this collection. If the collection changes, it means that it contained evicted nodes, and
-         * thus is not up to date. In this case we need to compute selected nodes again. Another
-         * case where we need to deeply compute selected nodes is when selectedNodes is empty (not
-         * computed yet) and we aren't in the context of the direct parent of the node.
+         * thus is not up to date.
          */
-        if (selectedNodes.removeAll(toevict) 
-                || (selectedNodes.isEmpty() 
+        boolean evictedInSelected = selectedNodes.removeAll(toevict);
+        /*
+         * Another case where we need to deeply compute selected nodes is when selectedNodes is
+         * empty (not computed yet) and we aren't in the context of the direct parent of the node.
+         */
+        if (evictedInSelected || (selectedNodes.isEmpty() 
                         && !node.getParent().getNode().equals(ancestor.getNode()))) {
+            // In this case we need to compute selected nodes again. 
             Collection deps = ancestor.getNode().getDependencies(
                 node.getRootModuleConf(), 
                 ancestor.getNode().getConfigurations(node.getRootModuleConf()));

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java?rev=1097621&r1=1097620&r2=1097621&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java Thu Apr 28 21:39:46 2011
@@ -154,6 +154,11 @@ public class VisitNode {
         return root;
     }
 
+    /**
+     * Get an ordered collection with the nodes from the root to this node
+     * 
+     * @return
+     */
     public Collection/*<VisitNode>*/ getPath() {
         if (path == null) {
             path = computePath();

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java?rev=1097621&r1=1097620&r2=1097621&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java Thu Apr 28 21:39:46 2011
@@ -40,6 +40,15 @@ public final class ExtendableItemHelper 
         return ret;
     }
 
+    /**
+     * Extract from the XML attribute the extra Ivy ones
+     * 
+     * @param settings
+     * @param attributes
+     * @param ignoredAttNames
+     *            the XML attributes names which are not extra but Ivy core ones
+     * @return
+     */
     public static Map getExtraAttributes(
             ParserSettings settings, Attributes attributes, String[] ignoredAttNames) {
         Map ret = new HashMap();