ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r671546 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/core/resolve/ test/java/org/apache/ivy/core/resolve/ test/repositories/1/org2/mod2.3/jars/ test/repositories/1/org2/mod2.6/ivys/ test/repositories/IVY-283/
Date Wed, 25 Jun 2008 13:26:05 GMT
Author: xavier
Date: Wed Jun 25 06:26:03 2008
New Revision: 671546

URL: http://svn.apache.org/viewvc?rev=671546&view=rev
Log:
FIX: Transitive dependencies resolves incorrectly when different modules uses the same dependency
with different configurations in the same build (IVY-541)

Added:
    ant/ivy/core/trunk/test/repositories/1/org2/mod2.3/jars/mod2.3-0.5.jar   (with props)
    ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.5.xml   (with props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
    ant/ivy/core/trunk/test/repositories/IVY-283/ivy-d.xml

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=671546&r1=671545&r2=671546&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Jun 25 06:26:03 2008
@@ -90,6 +90,7 @@
 - IMPROVEMENT: Change allownomd and skipbuildwithoutivy into a more semantically correct
name (IVY-297)
 - IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher
and GlobPatternMatcher
 
+- FIX: Transitive dependencies resolves incorrectly when different modules uses the same
dependency with different configurations in the same build (IVY-541)
 - FIX: transitive attribute set to false because of dependency (IVY-105)
 - FIX: Wrong check for defaultCacheArtifactPattern (IVY-840)
 - FIX: NPE in ivy:install if ivy.settings.xml contains custom attribute for a module (IVY-838)

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=671546&r1=671545&r2=671546&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 Wed Jun 25 06:26:03
2008
@@ -254,8 +254,7 @@
         } else {
             DependencyDescriptor dd = getDependencyDescriptor(parent);
             if (dd != null) {
-                usage.addDependencyArtifacts(rootModuleConf, dd.getDependencyArtifacts(parentConf));
-                usage.addDependencyIncludes(rootModuleConf, dd.getIncludeRules(parentConf));
+                usage.addUsage(rootModuleConf, dd, parentConf);
             }
             return loaded;
         }
@@ -276,10 +275,7 @@
         resolved.loadData(rootModuleConf, parent, parentConf, conf, shouldBePublic);
         DependencyDescriptor dd = getDependencyDescriptor(parent);
         if (dd != null) {
-            resolved.usage.addDependencyArtifacts(rootModuleConf, dd
-                    .getDependencyArtifacts(parentConf));
-            resolved.usage.addDependencyIncludes(rootModuleConf, dd
-                    .getIncludeRules(parentConf));
+            resolved.usage.addUsage(rootModuleConf, dd, parentConf);
         }
         
         data.replaceNode(getId(), resolved, rootModuleConf); // this actually discards the
node

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java?rev=671546&r1=671545&r2=671546&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java Wed Jun 25 06:26:03
2008
@@ -26,6 +26,7 @@
 import java.util.Set;
 
 import org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.IncludeRule;
 
 /**
@@ -85,6 +86,16 @@
         }
     }
     
+    private static final class Depender {
+        private DependencyDescriptor dd;
+        private String dependerConf;
+        
+        public Depender(DependencyDescriptor dd, String dependerConf) {
+            this.dd = dd;
+            this.dependerConf = dependerConf;
+        }
+    }
+    
     private IvyNode node;
 
     // Map (String rootConfName -> Set(String confName))
@@ -94,12 +105,8 @@
 
     // Map (NodeConf in -> Set(String conf))
     private Map requiredConfs = new HashMap();
-
-    // Map (String rootModuleConf -> Set(DependencyArtifactDescriptor))
-    private Map dependencyArtifacts = new HashMap();
-
-    // Map (String rootModuleConf -> Set(IncludeRule))
-    private Map dependencyIncludes = new HashMap();
+    
+    private Map /*<String, Set<Depender>>*/ dependers = new HashMap();
     
     // Map (String rootModuleConf -> IvyNodeBlacklist)
     private Map blacklisted = new HashMap();
@@ -147,7 +154,7 @@
         updateMapOfSetForKey(usage.rootModuleConfs, rootModuleConfs, rootModuleConf);
 
         // update dependencyArtifacts
-        updateMapOfSetForKey(usage.dependencyArtifacts, dependencyArtifacts, rootModuleConf);
+        updateMapOfSetForKey(usage.dependers, dependers, rootModuleConf);
     }
 
     private void updateMapOfSet(Map from, Map to) {
@@ -169,31 +176,62 @@
         }
     }
 
-    protected void addDependencyArtifacts(String rootModuleConf,
-            DependencyArtifactDescriptor[] dependencyArtifacts) {
-        addObjectsForConf(rootModuleConf, Arrays.asList(dependencyArtifacts),
-            this.dependencyArtifacts);
-    }
-
-    protected void addDependencyIncludes(String rootModuleConf, IncludeRule[] rules) {
-        addObjectsForConf(rootModuleConf, Arrays.asList(rules), dependencyIncludes);
-    }
-
-    private void addObjectsForConf(String rootModuleConf, Collection objectsToAdd, Map map)
{
+//    protected void addDependencyArtifacts(String rootModuleConf,
+//            DependencyArtifactDescriptor[] dependencyArtifacts) {
+//        addObjectsForConf(rootModuleConf, Arrays.asList(dependencyArtifacts),
+//            this.dependencyArtifacts);
+//    }
+//
+//    protected void addDependencyIncludes(String rootModuleConf, IncludeRule[] rules) {
+//        addObjectsForConf(rootModuleConf, Arrays.asList(rules), dependencyIncludes);
+//    }
+//
+    private void addObjectsForConf(String rootModuleConf, Object objectToAdd, Map map) {
         Set set = (Set) map.get(rootModuleConf);
         if (set == null) {
             set = new HashSet();
             map.put(rootModuleConf, set);
         }
-        set.addAll(objectsToAdd);
+        set.add(objectToAdd);
+    }
+
+    public void addUsage(String rootModuleConf, DependencyDescriptor dd, String parentConf)
{
+        addObjectsForConf(rootModuleConf, new Depender(dd, parentConf), dependers);
     }
 
     protected Set getDependencyArtifactsSet(String rootModuleConf) {
-        return (Set) dependencyArtifacts.get(rootModuleConf);
+        Collection dependersInConf = (Collection) dependers.get(rootModuleConf);
+        if (dependersInConf == null) {
+            return null;
+        }
+        Set dependencyArtifacts = new HashSet();
+        for (Iterator iterator = dependersInConf.iterator(); iterator.hasNext();) {
+            Depender depender = (Depender) iterator.next();
+            DependencyArtifactDescriptor[] dads = 
+                depender.dd.getDependencyArtifacts(depender.dependerConf);
+            dependencyArtifacts.addAll(Arrays.asList(dads));
+        }
+        return dependencyArtifacts;
     }
 
     protected Set getDependencyIncludesSet(String rootModuleConf) {
-        return (Set) dependencyIncludes.get(rootModuleConf);
+        Collection dependersInConf = (Collection) dependers.get(rootModuleConf);
+        if (dependersInConf == null) {
+            return null;
+        }
+        Set dependencyIncludes = new HashSet();
+        for (Iterator iterator = dependersInConf.iterator(); iterator.hasNext();) {
+            Depender depender = (Depender) iterator.next();
+            IncludeRule[] rules = 
+                depender.dd.getIncludeRules(depender.dependerConf);
+            if (rules == null || rules.length == 0) {
+                // no include rule in at least one depender -> we must include everything,

+                // and so return no include rule at all
+                return null;
+            }
+            dependencyIncludes.addAll(Arrays.asList(rules));
+        }
+        return dependencyIncludes;
     }
 
     protected void removeRootModuleConf(String rootModuleConf) {

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=671546&r1=671545&r2=671546&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Wed Jun 25 06:26:03
2008
@@ -1281,6 +1281,21 @@
         assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists());
     }
 
+    public void testResolveWithIncludeArtifactsTransitive() throws Exception {
+        // test case for IVY-541
+        // mod2.6 depends on mod2.3 and mod2.1
+        // mod2.3 depends on mod2.1 and selects its artifacts
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org2/mod2.6/ivys/ivy-0.5.xml").toURL(),
+            getResolveOptions(new String[] {"*"}));
+        assertFalse(report.hasError());
+
+        assertTrue(getIvyFileInCache(
+            ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists());
+        assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists());
+        assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists());
+    }
+
     public void testResolveWithExcludesArtifacts() throws Exception {
         // mod2.3 depends on mod2.1 and selects its artifacts
         ResolveReport report = ivy.resolve(new File(

Added: ant/ivy/core/trunk/test/repositories/1/org2/mod2.3/jars/mod2.3-0.5.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/org2/mod2.3/jars/mod2.3-0.5.jar?rev=671546&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ant/ivy/core/trunk/test/repositories/1/org2/mod2.3/jars/mod2.3-0.5.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.5.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.5.xml?rev=671546&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.5.xml (added)
+++ ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.5.xml Wed Jun 25 06:26:03
2008
@@ -0,0 +1,29 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.0">
+	<info organisation="org2"
+	       module="mod2.6"
+	       revision="0.5"
+	       status="integration"
+	/>
+	<dependencies>
+		<dependency name="mod2.3" rev="0.5"/>
+		<dependency name="mod2.1" rev="0.3"/>
+	</dependencies>
+</ivy-module>

Propchange: ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.5.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.5.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/core/trunk/test/repositories/IVY-283/ivy-d.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-283/ivy-d.xml?rev=671546&r1=671545&r2=671546&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-283/ivy-d.xml (original)
+++ ant/ivy/core/trunk/test/repositories/IVY-283/ivy-d.xml Wed Jun 25 06:26:03 2008
@@ -28,16 +28,16 @@
   </publications>
   <dependencies>
     <dependency name="module_b" rev="latest.integration" conf="build">
-      <artifact name="lib_b_a" type="jar" />
+      <include name="lib_b_a" type="jar" />
     </dependency>
     <dependency name="module_c" rev="latest.integration" conf="build">
-      <artifact name="lib_c_a" type="jar" />
+      <include name="lib_c_a" type="jar" />
     </dependency>
     <dependency name="module_a" rev="latest.integration" conf="build">
-      <artifact name="lib_a_a" type="jar" />
-      <artifact name="lib_a_c" type="jar" />
-      <artifact name="lib_a_d" type="jar" />
-      <artifact name="lib_a_e" type="jar" />
+      <include name="lib_a_a" type="jar" />
+      <include name="lib_a_c" type="jar" />
+      <include name="lib_a_d" type="jar" />
+      <include name="lib_a_e" type="jar" />
     </dependency>
   </dependencies>
 </ivy-module>



Mime
View raw message