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 2012/08/28 17:09:13 UTC

svn commit: r1378164 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/core/resolve/ test/java/org/apache/ivy/core/resolve/ test/repositories/1/org2/mod2.6/ivys/

Author: hibou
Date: Tue Aug 28 15:09:12 2012
New Revision: 1378164

URL: http://svn.apache.org/viewvc?rev=1378164&view=rev
Log:
Fix global exclude rule in root ivy files

Added:
    ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.14.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/IvyNodeCallers.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1378164&r1=1378163&r2=1378164&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Aug 28 15:09:12 2012
@@ -146,6 +146,7 @@ for detailed view of each issue, please 
 - FIX: The ignore circular dependency strategy is clobbering the warn strategy (IVY-1353) (Thanks to Carl Quinn)
 - FIX: Buildnumber and IvyFindRevision Ant tasks should honour defaultBranch setting (IVY-1344) (Thanks to Ales Nosek)
 - FIX: ApacheURLLister.retrieveListing() fails if the encoding of the URL list is different from the default encoding (IVY-1060) (Thanks to Robin Fernandes)
+- FIX: global exclude rules is not applying to root ivy files
 
 - NEW: Support Conditional Setting of a Property (IVY-1367)
 - NEW: Exposing some parent metadata (organisation, module, revision, branch) as properties (IVY-1288) (Thanks to Jean-Louis Boudart)

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=1378164&r1=1378163&r2=1378164&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 Tue Aug 28 15:09:12 2012
@@ -336,7 +336,7 @@ public class IvyNode implements Comparab
                 continue;
             }
             ModuleRevisionId requestedDependencyRevisionId = dd.getDependencyRevisionId();
-            if (isDependencyModuleExcluded(rootModuleConf, requestedDependencyRevisionId, conf)) {
+            if (isDependencyModuleExcluded(dd, rootModuleConf, requestedDependencyRevisionId, conf)) {
                 // the whole module is excluded, it is considered as not being part of dependencies
                 // at all
                 Message.verbose("excluding " + dd + " in " + conf);
@@ -380,10 +380,40 @@ public class IvyNode implements Comparab
         return (DependencyDescriptor) dds.get(parent);
     }
 
-    private boolean isDependencyModuleExcluded(String rootModuleConf,
+    private boolean isDependencyModuleExcluded(DependencyDescriptor dd, String rootModuleConf,
             ModuleRevisionId dependencyRevisionId, String conf) {
-        return callers.doesCallersExclude(rootModuleConf, DefaultArtifact.newIvyArtifact(
-            dependencyRevisionId, null));
+        Artifact a = DefaultArtifact.newIvyArtifact(dependencyRevisionId, null);
+        if (isRoot()) {
+            // no callers, but maybe some exclude
+            Boolean exclude = doesExclude(md, rootModuleConf, new String[] {rootModuleConf}, dd, a,
+                new Stack());
+            return exclude == null ? false : exclude.booleanValue();
+        }
+        return callers.doesCallersExclude(rootModuleConf, a);
+    }
+
+    Boolean doesExclude(ModuleDescriptor md, String rootModuleConf, String[] moduleConfs,
+            DependencyDescriptor dd, Artifact artifact, Stack callersStack) {
+        // artifact is excluded if it match any of the exclude pattern for this dependency...
+        if (dd != null) {
+            if (dd.doesExclude(moduleConfs, artifact.getId().getArtifactId())) {
+                return Boolean.TRUE;
+            }
+        }
+        if (md.doesExclude(moduleConfs, artifact.getId().getArtifactId())) {
+            return Boolean.TRUE;
+        }
+        // ... or if it is excluded by all its callers
+        IvyNode c = getData().getNode(md.getModuleRevisionId());
+        if (c != null) {
+            if (callersStack.contains(c.getId())) {
+                // a circular dependency, we cannot be conclusive here
+                return null;
+            }
+            return Boolean.valueOf(c.doesCallersExclude(rootModuleConf, artifact, callersStack));
+        } else {
+            return Boolean.FALSE;
+        }
     }
 
     public boolean hasConfigurationsToLoad() {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java?rev=1378164&r1=1378163&r2=1378164&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java Tue Aug 28 15:09:12 2012
@@ -278,7 +278,7 @@ public class IvyNodeCallers {
                     return false;
                 }
                 ModuleDescriptor md = callers[i].getModuleDescriptor();
-                Boolean doesExclude = doesExclude(md, rootModuleConf, callers[i].getCallerConfigurations(),
+                Boolean doesExclude = node.doesExclude(md, rootModuleConf, callers[i].getCallerConfigurations(),
                     callers[i].getDependencyDescriptor(), artifact, callersStack);
                 if (doesExclude != null) {
                     if (!doesExclude.booleanValue()) {
@@ -293,28 +293,4 @@ public class IvyNodeCallers {
         }
     }
 
-    private Boolean doesExclude(ModuleDescriptor md, String rootModuleConf, String[] moduleConfs,
-            DependencyDescriptor dd, Artifact artifact, Stack callersStack) {
-        // artifact is excluded if it match any of the exclude pattern for this dependency...
-        if (dd != null) {
-            if (dd.doesExclude(moduleConfs, artifact.getId().getArtifactId())) {
-                return Boolean.TRUE;
-            }
-        }
-        if (md.doesExclude(moduleConfs, artifact.getId().getArtifactId())) {
-            return Boolean.TRUE;
-        }
-        // ... or if it is excluded by all its callers
-        IvyNode c = node.getData().getNode(md.getModuleRevisionId());
-        if (c != null) {
-            if (callersStack.contains(c.getId())) {
-                // a circular dependency, we cannot be conclusive here
-                return null;
-            }
-            return Boolean.valueOf(c.doesCallersExclude(rootModuleConf, artifact, callersStack));
-        } else {
-            return Boolean.FALSE;
-        }
-    }
-
 }

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=1378164&r1=1378163&r2=1378164&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 Tue Aug 28 15:09:12 2012
@@ -3861,6 +3861,18 @@ public class ResolveTest extends TestCas
             ModuleRevisionId.newInstance("org2", "mod2.3", "0.4")).exists());
     }
 
+    public void testResolveExcludesConf3() throws Exception {
+        ResolveReport report = ivy.resolve(new File(
+                "test/repositories/1/org2/mod2.6/ivys/ivy-0.14.xml"),
+            getResolveOptions(new String[] {"exclude"}));
+        ModuleDescriptor md = report.getModuleDescriptor();
+        assertEquals(ModuleRevisionId.newInstance("org2", "mod2.6", "0.14"), md
+                .getModuleRevisionId());
+
+        assertFalse(getIvyFileInCache(
+            ModuleRevisionId.newInstance("org2", "mod2.5", "0.9")).exists());
+    }
+
     public void testResolveExceptConfiguration() throws Exception {
         // mod10.2 depends on mod5.1 conf *, !A
         ivy.resolve(new File("test/repositories/2/mod10.2/ivy-2.0.xml"),

Added: ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.14.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.14.xml?rev=1378164&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.14.xml (added)
+++ ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.14.xml Tue Aug 28 15:09:12 2012
@@ -0,0 +1,35 @@
+<!--
+   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.14"
+	       status="integration"
+	/>
+    <configurations>
+        <conf name="default" />
+        <conf name="include" extends="default" />
+        <conf name="exclude" extends="default" />
+    </configurations>
+	<dependencies>
+		<dependency name="mod2.3" rev="0.4" conf="include->default" />
+		<dependency name="mod2.5" rev="0.9" conf="default->default" />
+        <exclude module="mod2.5" conf="exclude" />
+	</dependencies>
+</ivy-module>

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

Propchange: ant/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.14.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

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