You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/04/03 17:45:56 UTC

svn commit: r525217 [1/2] - in /incubator/ivy/core/trunk: ./ src/java/org/apache/ivy/core/module/descriptor/ src/java/org/apache/ivy/core/resolve/ src/java/org/apache/ivy/plugins/parser/m2/ src/java/org/apache/ivy/plugins/parser/xml/ src/java/org/apach...

Author: xavier
Date: Tue Apr  3 10:45:54 2007
New Revision: 525217

URL: http://svn.apache.org/viewvc?view=rev&rev=525217
Log:
NEW: Module wide exclude (IVY-431)

Added:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractIncludeExcludeRule.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ConfigurationAware.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java
    incubator/ivy/core/trunk/test/repositories/1/org2/mod2.6/ivys/ivy-0.11.xml
Modified:
    incubator/ivy/core/trunk/CHANGES.txt
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyArtifactDescriptor.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParserTester.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update.xml
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/updated.xml
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/URLResolverTest.java

Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Tue Apr  3 10:45:54 2007
@@ -47,6 +47,7 @@
    version in SVN
 =====================================
 - NEW: define artifacts not declared by the dependency module descriptor (IVY-419)
+- NEW: Module wide exclude (IVY-431)
 
 - IMPROVE: Let user specify Ivy file when using a post-resolve task (IVY-455)
 - IMPROVE: IvyArtifactProperty and IvyArtifactReport tasks should be a post resolve task (IVY-452)

Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractIncludeExcludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractIncludeExcludeRule.java?view=auto&rev=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractIncludeExcludeRule.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractIncludeExcludeRule.java Tue Apr  3 10:45:54 2007
@@ -0,0 +1,94 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivy.core.module.descriptor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.ivy.core.IvyPatternHelper;
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+import org.apache.ivy.util.extendable.UnmodifiableExtendableItem;
+
+/**
+ * Abstract class used as implementation for both {@link IncludeRule} and {@link ExcludeRule},
+ * since their contract is almost identical
+ * 
+ * @author Xavier Hanin
+ *
+ */
+public abstract class AbstractIncludeExcludeRule extends UnmodifiableExtendableItem 
+		implements ConfigurationAware {
+
+    private ArtifactId _id;
+    private Collection _confs = new ArrayList();
+    private PatternMatcher _patternMatcher;
+    
+    public AbstractIncludeExcludeRule(ArtifactId aid, PatternMatcher matcher, Map extraAttributes) {
+    	super(null, extraAttributes);
+        _id = aid;
+        _patternMatcher = matcher;
+        initStandardAttributes();
+    }
+
+	private void initStandardAttributes() {
+		setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, _id.getModuleId().getOrganisation());
+        setStandardAttribute(IvyPatternHelper.MODULE_KEY, _id.getModuleId().getName());
+        setStandardAttribute(IvyPatternHelper.ARTIFACT_KEY, _id.getName());
+        setStandardAttribute(IvyPatternHelper.TYPE_KEY, _id.getType());
+        setStandardAttribute(IvyPatternHelper.EXT_KEY, _id.getExt());
+        setStandardAttribute("matcher", _patternMatcher.getName());
+	}
+    
+	public boolean equals(Object obj) {
+        if (!(obj instanceof AbstractIncludeExcludeRule)) {
+            return false;
+        }
+        AbstractIncludeExcludeRule rule = (AbstractIncludeExcludeRule)obj;
+        return getId().equals(rule.getId());
+    }
+    
+    public int hashCode() {
+        return getId().hashCode();
+    }
+    
+    /**
+     * Add a configuration for this rule
+     * @param conf
+     */
+    public void addConfiguration(String conf) {
+        _confs.add(conf);
+    }
+        
+    public ArtifactId getId() {
+        return _id;
+    }
+
+    public String[] getConfigurations() {
+        return (String[])_confs.toArray(new String[_confs.size()]);
+    }
+
+    public PatternMatcher getMatcher() {
+        return _patternMatcher;
+    }
+
+	public String toString() {
+		return _id+"("+_confs+")";
+	}
+}

Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ConfigurationAware.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ConfigurationAware.java?view=auto&rev=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ConfigurationAware.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ConfigurationAware.java Tue Apr  3 10:45:54 2007
@@ -0,0 +1,38 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivy.core.module.descriptor;
+
+/**
+ * Objects implementing this interface are aware of module configurations,
+ * and can thus be added to configurations, and list their configurations.
+ * 
+ * @author Xavier Hanin
+ */
+public interface ConfigurationAware {
+    /**
+     * Returns the configurations of the module to which the object is attached
+     * @return an array of configuration names to which the object is attached
+     */
+    public String[] getConfigurations();
+
+    /**
+     * Tells this object that it will now be part of the given configuration
+     * @param confName the name of the configuration to which the object is now attached
+     */
+    public void addConfiguration(String confName);
+}

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyArtifactDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyArtifactDescriptor.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyArtifactDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyArtifactDescriptor.java Tue Apr  3 10:45:54 2007
@@ -23,76 +23,48 @@
 import java.util.Map;
 
 import org.apache.ivy.core.IvyPatternHelper;
-import org.apache.ivy.core.module.id.ArtifactId;
-import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.util.extendable.UnmodifiableExtendableItem;
 
 
 public class DefaultDependencyArtifactDescriptor extends UnmodifiableExtendableItem
-	implements DependencyArtifactDescriptor {
+	implements DependencyArtifactDescriptor, ConfigurationAware {
 
-    private DefaultDependencyDescriptor _dd;
-    private ArtifactId _id;
     private Collection _confs = new ArrayList();
-    private boolean _includes;
-    private boolean _assumePublished;
-    private PatternMatcher _patternMatcher;
 	private URL _url;
-    
-    public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd,
-            String name, String type, String ext, boolean includes, PatternMatcher matcher) {
-		this(dd, name, type, ext, null, includes, false, matcher, null);
-	}
-    /**
+	private String _name;
+	private String _type;
+	private String _ext;
+ 
+	/**
      * @param dd
      * @param name
      * @param type
      * @param url 
      */
-    public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd,
-            String name, String type, String ext, URL url, boolean includes, boolean assumePublished, PatternMatcher matcher, Map extraAttributes) {
+    public DefaultDependencyArtifactDescriptor(
+    		String name, String type, String ext, URL url, Map extraAttributes) {
     	super(null, extraAttributes);
-        if (dd == null) {
-            throw new NullPointerException("dependency descriptor must not be null");
-        }
         if (name == null) {
             throw new NullPointerException("name must not be null");
         }
         if (type == null) {
             throw new NullPointerException("type must not be null");
         }
-        _dd = dd;
-        _id = new ArtifactId(dd.getDependencyId(), name, type, ext);
-        _includes = includes;
-        _url = url;
-        _patternMatcher = matcher;
-        _assumePublished = assumePublished;
-        initStandardAttributes();
-    }
-
-    public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd, ArtifactId aid, boolean includes, boolean assumePublished, PatternMatcher matcher, Map extraAttributes) {
-    	super(null, extraAttributes);
-        if (dd == null) {
-            throw new NullPointerException("dependency descriptor must not be null");
+        if (ext == null) {
+            throw new NullPointerException("ext must not be null");
         }
-        _dd = dd;
-        _id = aid;
-        _includes = includes;
-        _patternMatcher = matcher;
-        _assumePublished = assumePublished;
+        _name = name;
+        _type = type;
+        _ext = ext;
+        _url = url;
         initStandardAttributes();
     }
 
 	private void initStandardAttributes() {
-		setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, _id.getModuleId().getOrganisation());
-        setStandardAttribute(IvyPatternHelper.MODULE_KEY, _id.getModuleId().getName());
-        setStandardAttribute(IvyPatternHelper.ARTIFACT_KEY, _id.getName());
-        setStandardAttribute(IvyPatternHelper.TYPE_KEY, _id.getType());
-        setStandardAttribute(IvyPatternHelper.EXT_KEY, _id.getExt());
+        setStandardAttribute(IvyPatternHelper.ARTIFACT_KEY, getName());
+        setStandardAttribute(IvyPatternHelper.TYPE_KEY, getType());
+        setStandardAttribute(IvyPatternHelper.EXT_KEY, getExt());
         setStandardAttribute("url", _url != null ? String.valueOf(_url) : "");
-        setStandardAttribute("matcher", _patternMatcher.getName());
-        setStandardAttribute("assumePublished", String.valueOf(_assumePublished));
-        setStandardAttribute("includes", String.valueOf(_includes));
 	}
     
 	public boolean equals(Object obj) {
@@ -100,62 +72,42 @@
             return false;
         }
         DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)obj;
-        return getId().equals(dad.getId());
+        return getAttributes().equals(dad.getAttributes());
     }
     
     public int hashCode() {
-        return getId().hashCode();
+        return getAttributes().hashCode();
     }
     
     /**
-     * Add a configuration for this artifact (includes or excludes depending on this type dependency artifact descriptor).
-     * This method also updates the corresponding dependency descriptor
+     * Add a configuration for this artifact.
      * @param conf
      */
     public void addConfiguration(String conf) {
         _confs.add(conf);
-        if (_includes) {
-            _dd.addDependencyArtifactIncludes(conf, this);
-        } else {
-            _dd.addDependencyArtifactExcludes(conf, this);
-        }
     }
         
-    public DependencyDescriptor getDependency() {
-        return _dd;
-    }
-    
-    public ArtifactId getId() {
-        return _id;
-    }
-
     public String getName() {
-        return _id.getName();
+        return _name;
     }
 
     public String getType() {
-        return _id.getType();
+        return _type;
     }
     public String getExt() {
-        return _id.getExt();
+        return _ext;
     }
 
     public String[] getConfigurations() {
         return (String[])_confs.toArray(new String[_confs.size()]);
     }
 
-    public PatternMatcher getMatcher() {
-        return _patternMatcher;
-    }
 
 	public URL getUrl() {
 		return _url;
 	}
 
 	public String toString() {
-		return (_includes?"I":"E")+":"+_id+"("+_confs+")"+(_url==null?"":_url.toString());
-	}
-	public boolean isAssumePublished() {
-		return _assumePublished;
+		return "DA:"+_name+"."+_ext+"("+_type+") "+"("+_confs+")"+(_url==null?"":_url.toString());
 	}
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java Tue Apr  3 10:45:54 2007
@@ -20,6 +20,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -95,16 +96,18 @@
             if (dd instanceof DefaultDependencyDescriptor) {
                 DefaultDependencyDescriptor ddd = (DefaultDependencyDescriptor)dd;
                 newdd._confs = new LinkedHashMap(ddd._confs);
-                newdd._artifactsExcludes = new LinkedHashMap(ddd._artifactsExcludes);
-                newdd._artifactsIncludes = new LinkedHashMap(ddd._artifactsIncludes);
+                newdd._excludeRules = new LinkedHashMap(ddd._excludeRules);
+                newdd._includeRules = new LinkedHashMap(ddd._includeRules);
+                newdd._dependencyArtifacts = new LinkedHashMap(ddd._dependencyArtifacts);
             } else {
                 throw new IllegalArgumentException("dependency descriptor transformation does not support * module confs with descriptors which aren't DefaultDependencyDescriptor");
             }
         } else {
             for (int i = 0; i < moduleConfs.length; i++) {
                 newdd._confs.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyConfigurations(moduleConfs[i]))));
-                newdd._artifactsExcludes.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyArtifactsExcludes(moduleConfs[i]))));
-                newdd._artifactsIncludes.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyArtifactsIncludes(moduleConfs[i]))));
+                newdd._excludeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getExcludeRules(moduleConfs[i]))));
+                newdd._includeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getIncludeRules(moduleConfs[i]))));
+                newdd._dependencyArtifacts.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getIncludeRules(moduleConfs[i]))));
             }
         }
         if (fromSystem) {
@@ -115,8 +118,9 @@
     
     private ModuleRevisionId _revId;
     private Map _confs = new LinkedHashMap();
-    private Map _artifactsIncludes = new LinkedHashMap(); // Map (String masterConf -> Collection(DependencyArtifactDescriptor))
-    private Map _artifactsExcludes = new LinkedHashMap(); // Map (String masterConf -> Collection(DependencyArtifactDescriptor))
+    private Map _dependencyArtifacts = new LinkedHashMap(); // Map (String masterConf -> Collection(DependencyArtifactDescriptor))
+    private Map _includeRules = new LinkedHashMap(); // Map (String masterConf -> Collection(IncludeRule))
+    private Map _excludeRules = new LinkedHashMap(); // Map (String masterConf -> Collection(ExcludeRule))
     private Set _extends = new LinkedHashSet();
     
     /**
@@ -148,8 +152,8 @@
         String[] moduleConfs = dd.getModuleConfigurations();
         for (int i = 0; i < moduleConfs.length; i++) {
             _confs.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyConfigurations(moduleConfs[i]))));
-            _artifactsExcludes.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyArtifactsExcludes(moduleConfs[i]))));
-            _artifactsIncludes.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getDependencyArtifactsIncludes(moduleConfs[i]))));
+            _excludeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getExcludeRules(moduleConfs[i]))));
+            _includeRules.put(moduleConfs[i], new ArrayList(Arrays.asList(dd.getIncludeRules(moduleConfs[i]))));
         }
     }
     
@@ -283,20 +287,27 @@
         return (String[]) confs.toArray(new String[confs.size()]);
     }
     
-    public DependencyArtifactDescriptor[] getDependencyArtifactsIncludes(String moduleConfiguration) {
-        return getDependencyArtifacts(moduleConfiguration, _artifactsIncludes);
+    public DependencyArtifactDescriptor[] getDependencyArtifacts(String moduleConfiguration) {
+        Collection artifacts = getCollectionForConfiguration(moduleConfiguration, _dependencyArtifacts);
+        return (DependencyArtifactDescriptor[]) artifacts.toArray(new DependencyArtifactDescriptor[artifacts.size()]);
+    }
+    
+    public IncludeRule[] getIncludeRules(String moduleConfiguration) {
+        Collection rules = getCollectionForConfiguration(moduleConfiguration, _includeRules);
+        return (IncludeRule[]) rules.toArray(new IncludeRule[rules.size()]);
     }
     
-    public DependencyArtifactDescriptor[] getDependencyArtifactsExcludes(String moduleConfiguration) {
-        return getDependencyArtifacts(moduleConfiguration, _artifactsExcludes);
+    public ExcludeRule[] getExcludeRules(String moduleConfiguration) {
+        Collection rules = getCollectionForConfiguration(moduleConfiguration, _excludeRules);
+        return (ExcludeRule[]) rules.toArray(new ExcludeRule[rules.size()]);
     }
     
-    private DependencyArtifactDescriptor[] getDependencyArtifacts(String moduleConfiguration, Map artifactsMap) {
-        if (artifactsMap.isEmpty()) { 
-            return new DependencyArtifactDescriptor[0];
+	private Set getCollectionForConfiguration(String moduleConfiguration, Map collectionMap) {
+		if (collectionMap.isEmpty()) { 
+            return Collections.EMPTY_SET;
         }
-        Collection artifacts = (Collection)artifactsMap.get(moduleConfiguration);
-        Collection defArtifacts = (Collection)artifactsMap.get("*");
+        Collection artifacts = (Collection)collectionMap.get(moduleConfiguration);
+        Collection defArtifacts = (Collection)collectionMap.get("*");
         Set ret = new LinkedHashSet();
         if (artifacts != null) {
             ret.addAll(artifacts);
@@ -304,40 +315,55 @@
         if (defArtifacts != null) {
             ret.addAll(defArtifacts);
         }
-        return (DependencyArtifactDescriptor[])ret.toArray(new DependencyArtifactDescriptor[ret.size()]);
-    }
+		return ret;
+	}
     
-    public DependencyArtifactDescriptor[] getDependencyArtifactsIncludes(String[] moduleConfigurations) {
+    public DependencyArtifactDescriptor[] getDependencyArtifacts(String[] moduleConfigurations) {
         Set artifacts = new LinkedHashSet();
         for (int i = 0; i < moduleConfigurations.length; i++) {
-            artifacts.addAll(Arrays.asList(getDependencyArtifactsIncludes(moduleConfigurations[i])));
+            artifacts.addAll(Arrays.asList(getDependencyArtifacts(moduleConfigurations[i])));
         }
         return (DependencyArtifactDescriptor[]) artifacts.toArray(new DependencyArtifactDescriptor[artifacts.size()]);
     }
     
-    public DependencyArtifactDescriptor[] getDependencyArtifactsExcludes(String[] moduleConfigurations) {
-        Set artifacts = new LinkedHashSet();
+    public IncludeRule[] getIncludeRules(String[] moduleConfigurations) {
+        Set rules = new LinkedHashSet();
         for (int i = 0; i < moduleConfigurations.length; i++) {
-            artifacts.addAll(Arrays.asList(getDependencyArtifactsExcludes(moduleConfigurations[i])));
+            rules.addAll(Arrays.asList(getIncludeRules(moduleConfigurations[i])));
         }
-        return (DependencyArtifactDescriptor[]) artifacts.toArray(new DependencyArtifactDescriptor[artifacts.size()]);
+        return (IncludeRule[]) rules.toArray(new IncludeRule[rules.size()]);
+    }
+    
+    public ExcludeRule[] getExcludeRules(String[] moduleConfigurations) {
+        Set rules = new LinkedHashSet();
+        for (int i = 0; i < moduleConfigurations.length; i++) {
+            rules.addAll(Arrays.asList(getExcludeRules(moduleConfigurations[i])));
+        }
+        return (ExcludeRule[]) rules.toArray(new ExcludeRule[rules.size()]);
     }
     
-    public DependencyArtifactDescriptor[] getAllDependencyArtifactsIncludes() {
-        return getAllDependencyArtifacts(_artifactsIncludes);
+    public DependencyArtifactDescriptor[] getAllDependencyArtifacts() {
+        Set ret = mergeAll(_dependencyArtifacts);
+		return (DependencyArtifactDescriptor[]) ret.toArray(new DependencyArtifactDescriptor[ret.size()]);
     }
     
-    public DependencyArtifactDescriptor[] getAllDependencyArtifactsExcludes() {
-        return getAllDependencyArtifacts(_artifactsExcludes);
+    public IncludeRule[] getAllIncludeRules() {
+        Set ret = mergeAll(_includeRules);
+		return (IncludeRule[]) ret.toArray(new IncludeRule[ret.size()]);
     }
     
-    private DependencyArtifactDescriptor[] getAllDependencyArtifacts(Map artifactsMap) {
+    public ExcludeRule[] getAllExcludeRules() {
+        Set ret = mergeAll(_excludeRules);
+		return (ExcludeRule[]) ret.toArray(new ExcludeRule[ret.size()]);
+    }
+    
+    private Set mergeAll(Map artifactsMap) {
         Set ret = new LinkedHashSet();
         for (Iterator it = artifactsMap.values().iterator(); it.hasNext();) {
             Collection artifacts = (Collection)it.next();
             ret.addAll(artifacts);
         }
-        return (DependencyArtifactDescriptor[])ret.toArray(new DependencyArtifactDescriptor[ret.size()]);
+        return ret;
     }
     
     public void addDependencyConfiguration(String masterConf, String depConf) {
@@ -359,21 +385,25 @@
         }
     }
     
-    public void addDependencyArtifactIncludes(String masterConf, DependencyArtifactDescriptor dad) {
-        addDependencyArtifacts(masterConf, dad, _artifactsIncludes);
+    public void addDependencyArtifact(String masterConf, DependencyArtifactDescriptor dad) {
+        addObjectToConfiguration(masterConf, dad, _dependencyArtifacts);
+    }
+    
+    public void addIncludeRule(String masterConf, IncludeRule rule) {
+        addObjectToConfiguration(masterConf, rule, _includeRules);
     }
     
-    public void addDependencyArtifactExcludes(String masterConf, DependencyArtifactDescriptor dad) {
-        addDependencyArtifacts(masterConf, dad, _artifactsExcludes);
+    public void addExcludeRule(String masterConf, ExcludeRule rule) {
+        addObjectToConfiguration(masterConf, rule, _excludeRules);
     }
     
-    private void addDependencyArtifacts(String masterConf, DependencyArtifactDescriptor dad, Map artifactsMap) {
-        Collection artifacts = (Collection)artifactsMap.get(masterConf);
-        if (artifacts == null) {
-            artifacts = new ArrayList();
-            artifactsMap.put(masterConf, artifacts);
+    private void addObjectToConfiguration(String callerConf, Object toAdd, Map confsMap) {
+        Collection col = (Collection)confsMap.get(callerConf);
+        if (col == null) {
+            col = new ArrayList();
+            confsMap.put(callerConf, col);
         }
-        artifacts.add(dad);
+        col.add(toAdd);
     }
     
     /**
@@ -383,9 +413,9 @@
         if (_namespace != null) {
             artifactId = NameSpaceHelper.transform(artifactId, _namespace.getFromSystemTransformer());
         }
-        DependencyArtifactDescriptor[] dads = getDependencyArtifactsExcludes(moduleConfigurations);
-        for (int i = 0; i < dads.length; i++) {
-            if (MatcherHelper.matches(dads[i].getMatcher(), dads[i].getId(), artifactId)) {
+        ExcludeRule[] rules = getExcludeRules(moduleConfigurations);
+        for (int i = 0; i < rules.length; i++) {
+            if (MatcherHelper.matches(rules[i].getMatcher(), rules[i].getId(), artifactId)) {
                 return true;
             }
         }        
@@ -397,7 +427,7 @@
      * @return
      */
     public boolean canExclude() {
-        return !_artifactsExcludes.isEmpty();
+        return !_excludeRules.isEmpty();
     }
     
     public void addExtends(String conf) {

Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java?view=auto&rev=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultExcludeRule.java Tue Apr  3 10:45:54 2007
@@ -0,0 +1,36 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivy.core.module.descriptor;
+
+import java.util.Map;
+
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+
+
+public class DefaultExcludeRule extends AbstractIncludeExcludeRule
+	implements ExcludeRule {
+
+	public DefaultExcludeRule(ArtifactId aid, PatternMatcher matcher, Map extraAttributes) {
+		super(aid, matcher, extraAttributes);
+	}
+
+	public String toString() {
+		return "E:"+super.toString();
+	}
+}

Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java?view=auto&rev=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultIncludeRule.java Tue Apr  3 10:45:54 2007
@@ -0,0 +1,36 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivy.core.module.descriptor;
+
+import java.util.Map;
+
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+
+
+public class DefaultIncludeRule extends AbstractIncludeExcludeRule
+	implements IncludeRule {
+
+	public DefaultIncludeRule(ArtifactId aid, PatternMatcher matcher, Map extraAttributes) {
+		super(aid, matcher, extraAttributes);
+	}
+
+	public String toString() {
+		return "I:"+super.toString();
+	}
+}

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java Tue Apr  3 10:45:54 2007
@@ -30,7 +30,9 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
+import org.apache.ivy.core.module.id.ArtifactId;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.module.status.StatusManager;
@@ -174,6 +176,7 @@
 	private boolean _mappingOverride;
 	private ModuleDescriptorParser _parser;
 	private Resource _resource;
+	private List _excludeRules = new ArrayList(); // List(ExcludeRule)
 
     public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate) {
         this(id, status, pubDate, false);
@@ -427,7 +430,7 @@
     public boolean isNamespaceUseful() {
         for (Iterator iter = _dependencies.iterator(); iter.hasNext();) {
             DependencyDescriptor dd = (DependencyDescriptor)iter.next();
-            if (dd.getAllDependencyArtifactsExcludes().length > 0) {
+            if (dd.getAllExcludeRules().length > 0) {
                 return true;
             }
         }
@@ -494,4 +497,45 @@
 		return _resource;
 	}
 
+	public void addExcludeRule(ExcludeRule rule) {
+		_excludeRules .add(rule);
+	}
+
+	public boolean canExclude() {
+		return !_excludeRules.isEmpty();
+	}
+    /**
+     * only works when namespace is properly set. The behaviour is not specified if namespace is not set
+     */
+    public boolean doesExclude(String[] moduleConfigurations, ArtifactId artifactId) {
+        if (_namespace != null) {
+            artifactId = NameSpaceHelper.transform(artifactId, _namespace.getFromSystemTransformer());
+        }
+        ExcludeRule[] rules = getExcludeRules(moduleConfigurations);
+        for (int i = 0; i < rules.length; i++) {
+            if (MatcherHelper.matches(rules[i].getMatcher(), rules[i].getId(), artifactId)) {
+                return true;
+            }
+        }        
+        return false;
+    }
+    public ExcludeRule[] getAllExcludeRules() {
+    	return (ExcludeRule[]) _excludeRules.toArray(new ExcludeRule[_excludeRules.size()]);
+    }
+    public ExcludeRule[] getExcludeRules(String[] moduleConfigurations) {
+        Set rules = new LinkedHashSet();
+        for (Iterator iter = _excludeRules.iterator(); iter.hasNext();) {
+			ExcludeRule rule = (ExcludeRule) iter.next();
+			String[] ruleConfs = rule.getConfigurations();
+			if (containsAny(ruleConfs, moduleConfigurations)) {
+				rules.add(rule);
+			}
+		}
+        return (ExcludeRule[]) rules.toArray(new ExcludeRule[rules.size()]);
+    }
+
+	private boolean containsAny(String[] arr1, String[] arr2) {
+		return new ArrayList(Arrays.asList(arr1))
+				.removeAll(Arrays.asList(arr2));
+	}
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyArtifactDescriptor.java Tue Apr  3 10:45:54 2007
@@ -19,30 +19,17 @@
 
 import java.net.URL;
 
-import org.apache.ivy.core.module.id.ArtifactId;
-import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.util.extendable.ExtendableItem;
 
 
 /**
  * This describes an artifact that is asked for a dependency.
  * 
- * It is used to resctrict the artifacts asked for a dependency, or describe them
- * when there is no ivy file.
+ * It is used to define an (additional) artifact not declared
+ * by a dependency module descriptor.
  */
 public interface DependencyArtifactDescriptor extends ExtendableItem {
     /**
-     * Returns the dependency descriptor in which this artifact is asked
-     * @return
-     */
-    public DependencyDescriptor getDependency();
-
-    /**
-     * Returns the id of the described artifact, without revision information
-     * @return
-     */
-    public ArtifactId getId();
-    /**
      * Returns the name of the artifact asked
      * @return
      */
@@ -67,20 +54,4 @@
      * @return an array of configuration names in which the artifact is asked
      */
     public String[] getConfigurations();
-    
-    /**
-     * Returns the matcher to use to know if an artifact match the current descriptor
-     * @return
-     */
-    public PatternMatcher getMatcher();
-    
-    /**
-     * Indicates if this artifact should be assumed to be published in the dependency.
-     * This is useful only for dependency artifact include, and is used
-     * to know if the artifact should be consider to be published in the dependency
-     * even if it isn't declared in the dependency module descriptor.
-     * @return true if the artifact should be assumed to be published in the dependency,
-     * false otherwise
-     */
-    public boolean isAssumePublished();
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DependencyDescriptor.java Tue Apr  3 10:45:54 2007
@@ -54,12 +54,21 @@
     String[] getDependencyConfigurations(String moduleConfiguration);
     String[] getDependencyConfigurations(String[] moduleConfigurations);
     Namespace getNamespace();
-    DependencyArtifactDescriptor[] getAllDependencyArtifactsIncludes();
-    DependencyArtifactDescriptor[] getDependencyArtifactsIncludes(String moduleConfigurations);
-    DependencyArtifactDescriptor[] getDependencyArtifactsIncludes(String[] moduleConfigurations);
-    DependencyArtifactDescriptor[] getAllDependencyArtifactsExcludes();
-    DependencyArtifactDescriptor[] getDependencyArtifactsExcludes(String moduleConfigurations);
-    DependencyArtifactDescriptor[] getDependencyArtifactsExcludes(String[] moduleConfigurations);
+    DependencyArtifactDescriptor[] getAllDependencyArtifacts();
+    DependencyArtifactDescriptor[] getDependencyArtifacts(String moduleConfigurations);
+    DependencyArtifactDescriptor[] getDependencyArtifacts(String[] moduleConfigurations);
+    IncludeRule[] getAllIncludeRules();
+    IncludeRule[] getIncludeRules(String moduleConfigurations);
+    IncludeRule[] getIncludeRules(String[] moduleConfigurations);
+    ExcludeRule[] getAllExcludeRules();
+    ExcludeRule[] getExcludeRules(String moduleConfigurations);
+    ExcludeRule[] getExcludeRules(String[] moduleConfigurations);
+    /**
+     * Returns true if
+     * @param moduleConfigurations
+     * @param artifactId
+     * @return
+     */
     boolean doesExclude(String[] moduleConfigurations, ArtifactId artifactId);
     /**
      * Returns true if this descriptor contains any exclusion rule

Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java?view=auto&rev=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ExcludeRule.java Tue Apr  3 10:45:54 2007
@@ -0,0 +1,49 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivy.core.module.descriptor;
+
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+import org.apache.ivy.util.extendable.ExtendableItem;
+
+
+/**
+ * This describes a rule of exclusion.
+ * 
+ * It is used to resctrict the artifacts asked for a dependency, 
+ * by excluding a whole module or some artifacts of a dependency.
+ */
+public interface ExcludeRule extends ExtendableItem {
+
+    /**
+     * Returns the id of the described artifact, without revision information
+     * @return
+     */
+    public ArtifactId getId();
+    /**
+     * Returns the configurations of the module in which the artifact is asked
+     * @return an array of configuration names in which the artifact is asked
+     */
+    public String[] getConfigurations();
+    
+    /**
+     * Returns the matcher to use to know if an artifact match the current descriptor
+     * @return
+     */
+    public PatternMatcher getMatcher();
+}

Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java?view=auto&rev=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/IncludeRule.java Tue Apr  3 10:45:54 2007
@@ -0,0 +1,49 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivy.core.module.descriptor;
+
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+import org.apache.ivy.util.extendable.ExtendableItem;
+
+/**
+ * This describes a rule of inclusion.
+ * 
+ * It is used to resctrict the artifacts and modules asked for a dependency, 
+ * by including only modules and artifacts matching the rule
+ */
+public interface IncludeRule extends ExtendableItem {
+
+    /**
+     * Returns the id of the described artifact, without revision information
+     * @return
+     */
+    public ArtifactId getId();
+    /**
+     * Returns the configurations of the module in which the artifact is asked
+     * @return an array of configuration names in which the artifact is asked
+     */
+    public String[] getConfigurations();
+    
+    /**
+     * Returns the matcher to use to know if an artifact match the current descriptor
+     * @return
+     */
+    public PatternMatcher getMatcher();
+
+}

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java Tue Apr  3 10:45:54 2007
@@ -22,6 +22,7 @@
 import java.text.ParseException;
 import java.util.Date;
 
+import org.apache.ivy.core.module.id.ArtifactId;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.plugins.conflict.ConflictManager;
@@ -139,4 +140,24 @@
 	 * @return
 	 */
 	Resource getResource();
+    /**
+     * Returns true if this descriptor contains any exclusion rule
+     * @return true if this descriptor contains any exclusion rule
+     */
+	boolean canExclude();
+	/**
+	 * Returns true if an exclude rule of this module attached to any of the given configurations
+	 * matches the given artifact id, and thus exclude it
+	 * @param moduleConfs
+	 * @param artifactId
+	 * @return
+	 */
+	boolean doesExclude(String[] moduleConfs, ArtifactId artifactId);
+	/**
+	 * Returns an array of all the exclude rules this module descriptor currently holds.
+	 * Module Descriptor exclude rules are used to exclude (usually transitive) dependencies
+	 * for the whole module.
+	 * @return an array of {@link ExcludeRule} this module descriptor holds
+	 */
+	public ExcludeRule[] getAllExcludeRules();
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java Tue Apr  3 10:45:54 2007
@@ -20,7 +20,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -41,6 +40,7 @@
 import org.apache.ivy.core.module.descriptor.DefaultArtifact;
 import org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.IncludeRule;
 import org.apache.ivy.core.module.descriptor.MDArtifact;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ArtifactId;
@@ -149,7 +149,10 @@
     private Map _requiredConfs = new HashMap(); 
     
     // Map (String rootModuleConf -> Set(DependencyArtifactDescriptor))
-    private Map _dependencyArtifactsIncludes = new HashMap();
+    private Map _dependencyArtifacts = new HashMap();
+
+    // Map (String rootModuleConf -> Set(IncludeRule))
+    private Map _dependencyIncludes = new HashMap();
 
 
     
@@ -240,7 +243,8 @@
                                 resolved.loadData(rootModuleConf, parent, parentConf, conf, shouldBePublic);
                                 DependencyDescriptor dd = dependencyDescriptor;
                                 if (dd != null) {
-                                    resolved.addDependencyArtifactsIncludes(rootModuleConf, dd.getDependencyArtifactsIncludes(parentConf));
+                                    resolved.addDependencyArtifacts(rootModuleConf, dd.getDependencyArtifacts(parentConf));
+                                    resolved.addDependencyIncludes(rootModuleConf, dd.getIncludeRules(parentConf));
                                 }
                                 _data.replaceNode(getId(), resolved, rootModuleConf); // this actually discards the node
 
@@ -297,7 +301,8 @@
         }
         DependencyDescriptor dd = getDependencyDescriptor(parent);
         if (dd != null) {
-            addDependencyArtifactsIncludes(rootModuleConf, dd.getDependencyArtifactsIncludes(parentConf));
+            addDependencyArtifacts(rootModuleConf, dd.getDependencyArtifacts(parentConf));
+            addDependencyIncludes(rootModuleConf, dd.getIncludeRules(parentConf));
         }
         return loaded;
         
@@ -647,7 +652,7 @@
         updateMapOfSetForKey(node._rootModuleConfs, _rootModuleConfs, rootModuleConf);
         
         // update dependencyArtifactsIncludes
-        updateMapOfSetForKey(node._dependencyArtifactsIncludes, _dependencyArtifactsIncludes, rootModuleConf);
+        updateMapOfSetForKey(node._dependencyArtifacts, _dependencyArtifacts, rootModuleConf);
         
         // update confsToFetch
         updateConfsToFetch(node._fetchedConfigurations);
@@ -726,27 +731,30 @@
         Set artifacts = new HashSet(); // the set we fill before returning
         
         // we check if we have dependencyArtifacts includes description for this rootModuleConf
-        Set includes = (Set)_dependencyArtifactsIncludes.get(rootModuleConf);
+        Set dependencyArtifacts = (Set)_dependencyArtifacts.get(rootModuleConf);
         
-        if (_md.isDefault() && includes != null && !includes.isEmpty()) {
+        if (_md.isDefault() && dependencyArtifacts != null && !dependencyArtifacts.isEmpty()) {
             // the descriptor is a default one: it has been generated from nothing
             // moreover, we have dependency artifacts description
             // these descritions are thus used as if they were declared in the module
             // descriptor. If one is not really present, the error will be raised
             // at download time
-            for (Iterator it = includes.iterator(); it.hasNext();) {
+            for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
                 DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)it.next();
                 artifacts.add(new MDArtifact(_md, dad.getName(), dad.getType(), dad.getExt(), dad.getUrl(), dad.getExtraAttributes()));
             }
         } else {
-            if (includes == null || includes.isEmpty()) {
-                // no artifacts includes: we get all artifacts as defined by the descriptor
+            Set includes = (Set)_dependencyIncludes.get(rootModuleConf);
+            
+            if ((dependencyArtifacts == null || dependencyArtifacts.isEmpty())
+            		&& (includes == null || includes.isEmpty())) {
+                // no artifacts / includes: we get all artifacts as defined by the descriptor
                 for (Iterator iter = confs.iterator(); iter.hasNext();) {
                     String conf = (String) iter.next();
                     artifacts.addAll(Arrays.asList(_md.getArtifacts(conf)));
                 }
             } else {
-                // we have to get only artifacts listed as "includes"
+            	// we have to get only artifacts listed as "includes"
                 
                 // first we get all artifacts as defined by the module descriptor
                 // and classify them by artifact id
@@ -759,26 +767,30 @@
                     }
                 }
                 
-                // now we can keep only listed ones
-                for (Iterator it = includes.iterator(); it.hasNext();) {
+                // now we add caller defined ones
+                for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
                     DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor)it.next();
-                    if (dad.isAssumePublished()) {
-                        artifacts.add(new MDArtifact(_md, dad.getName(), dad.getType(), dad.getExt(), dad.getUrl(), dad.getExtraAttributes()));
-                    } else {
-                    	Collection arts = findArtifactsMatching(dad, allArtifacts);
-                    	if (arts.isEmpty()) {
-                    		Message.error("a required artifact is not listed by module descriptor: "+dad.getId());
-                    		// we remove it from required list to prevent message to be displayed more than once
-                    		it.remove(); 
-                    	} else {
-                    		Message.debug(this+" in "+rootModuleConf+": including "+arts);
-                    		artifacts.addAll(arts);
-                    	}
-                    }
+                    artifacts.add(new MDArtifact(_md, dad.getName(), dad.getType(), dad.getExt(), 
+                    		dad.getUrl(), dad.getExtraAttributes()));
+                }
+                
+                // and now we filter according to include rules
+                for (Iterator it = includes.iterator(); it.hasNext();) {
+                	IncludeRule dad = (IncludeRule)it.next();
+                	Collection arts = findArtifactsMatching(dad, allArtifacts);
+                	if (arts.isEmpty()) {
+                		Message.error("a required artifact is not listed by module descriptor: "+dad.getId());
+                		// we remove it from required list to prevent message to be displayed more than once
+                		it.remove(); 
+                	} else {
+                		Message.debug(this+" in "+rootModuleConf+": including "+arts);
+                		artifacts.addAll(arts);
+                	}
                 }
             }
         }
         
+        
         // now excludes artifacts that aren't accepted by any caller
         for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
             Artifact artifact = (Artifact)iter.next();
@@ -791,28 +803,32 @@
         return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
     }
 
-    private static Collection findArtifactsMatching(DependencyArtifactDescriptor dad, Map allArtifacts) {
+    private static Collection findArtifactsMatching(IncludeRule rule, Map allArtifacts) {
         Collection ret = new ArrayList();
         for (Iterator iter = allArtifacts.keySet().iterator(); iter.hasNext();) {
             ArtifactId aid = (ArtifactId)iter.next();
-            if (MatcherHelper.matches(dad.getMatcher(), dad.getId(), aid)) {
+            if (MatcherHelper.matches(rule.getMatcher(), rule.getId(), aid)) {
                 ret.add(allArtifacts.get(aid));
             }
         }
         return ret;
     }
 
-    private void addDependencyArtifactsIncludes(String rootModuleConf, DependencyArtifactDescriptor[] dependencyArtifacts) {
-        addDependencyArtifacts(rootModuleConf, dependencyArtifacts, _dependencyArtifactsIncludes);
+    private void addDependencyArtifacts(String rootModuleConf, DependencyArtifactDescriptor[] dependencyArtifacts) {
+        addObjectsForConf(rootModuleConf, Arrays.asList(dependencyArtifacts), _dependencyArtifacts);
+    }
+
+    private void addDependencyIncludes(String rootModuleConf, IncludeRule[] rules) {
+    	addObjectsForConf(rootModuleConf, Arrays.asList(rules), _dependencyIncludes);
     }
 
-    private void addDependencyArtifacts(String rootModuleConf, DependencyArtifactDescriptor[] dependencyArtifacts, Map artifactsMap) {
-        Set depArtifacts = (Set) artifactsMap.get(rootModuleConf);
-        if (depArtifacts == null) {
-            depArtifacts = new HashSet();
-            artifactsMap.put(rootModuleConf, depArtifacts);
+    private void addObjectsForConf(String rootModuleConf, Collection objectsToAdd, Map map) {
+        Set set = (Set) map.get(rootModuleConf);
+        if (set == null) {
+            set = new HashSet();
+            map.put(rootModuleConf, set);
         }
-        depArtifacts.addAll(Arrays.asList(dependencyArtifacts));
+        set.addAll(objectsToAdd);
     }
     
     

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java Tue Apr  3 10:45:54 2007
@@ -86,7 +86,7 @@
             return _md;
         }
         public boolean canExclude() {
-            return _callerCanExclude || _dd.canExclude();
+            return _callerCanExclude || _md.canExclude() || _dd.canExclude();
         }
         public DependencyDescriptor getDependencyDescriptor() {
             return _dd;
@@ -225,6 +225,9 @@
             if (dd.doesExclude(moduleConfs, artifact.getId().getArtifactId())) {
                 return true;
             }
+        }
+        if (md.doesExclude(moduleConfs, artifact.getId().getArtifactId())) {
+            return true;
         }
         // ... or if it is excluded by all its callers
         IvyNode c = _node.getData().getNode(md.getModuleRevisionId());

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java Tue Apr  3 10:45:54 2007
@@ -37,6 +37,7 @@
 import org.apache.ivy.core.module.descriptor.DefaultArtifact;
 import org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor;
 import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.Configuration.Visibility;
 import org.apache.ivy.core.module.id.ArtifactId;
@@ -173,18 +174,13 @@
                     extraAtt.put("classifier", _classifier);
                     String[] confs = _dd.getModuleConfigurations();
                     for (int i = 0; i < confs.length; i++) {
-                    	_dd.addDependencyArtifactIncludes(
+                    	_dd.addDependencyArtifact(
                     			confs[i], 
                     			new DefaultDependencyArtifactDescriptor(
-                    					_dd, 
-                    					new ArtifactId(
-                    							_dd.getDependencyId(), 
-                    							_dd.getDependencyId().getName(), 
-                    							"jar", 
-                    							"jar"), // here we have to assume a type and ext for the artifact, so this is a limitation compared to how m2 behave with classifiers
-                    					false, 
-                    					true, // assumePublished = true, Ivy will actually assume this artifact (with the classifier extra artifact) is published by the dependency 
-                    					ExactPatternMatcher.INSTANCE,
+                    					_dd.getDependencyId().getName(), 
+                    					"jar", 
+                    					"jar", // here we have to assume a type and ext for the artifact, so this is a limitation compared to how m2 behave with classifiers
+                    					null,
                     					extraAtt));
                     }
                 }
@@ -192,16 +188,13 @@
                     ModuleId mid = (ModuleId)iter.next();
                     String[] confs = _dd.getModuleConfigurations();
                     for (int i = 0; i < confs.length; i++) {
-                        _dd.addDependencyArtifactExcludes(confs[i], 
-                        		new DefaultDependencyArtifactDescriptor(
-                        				_dd, 
+                        _dd.addExcludeRule(confs[i], 
+                        		new DefaultExcludeRule(
                         				new ArtifactId(
                         						mid, 
                         						PatternMatcher.ANY_EXPRESSION, 
                         						PatternMatcher.ANY_EXPRESSION, 
                         						PatternMatcher.ANY_EXPRESSION), 
-                						false, 
-                						false, 
                 						ExactPatternMatcher.INSTANCE,
                 						null));
                     }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java Tue Apr  3 10:45:54 2007
@@ -32,9 +32,15 @@
 
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.ConfigurationAware;
 import org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor;
 import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
+import org.apache.ivy.core.module.descriptor.DefaultIncludeRule;
 import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor;
+import org.apache.ivy.core.module.descriptor.ExcludeRule;
+import org.apache.ivy.core.module.descriptor.IncludeRule;
 import org.apache.ivy.core.module.descriptor.License;
 import org.apache.ivy.core.module.descriptor.MDArtifact;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
@@ -44,7 +50,6 @@
 import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.plugins.conflict.ConflictManager;
 import org.apache.ivy.plugins.conflict.FixedConflictManager;
-import org.apache.ivy.plugins.matcher.ExactPatternMatcher;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.plugins.namespace.Namespace;
 import org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser;
@@ -134,7 +139,7 @@
 	private static final List ALLOWED_VERSIONS = Arrays.asList(new String[] {"1.0", "1.1", "1.2", "1.3", "1.4","2.0"});
     
     private DefaultDependencyDescriptor _dd;
-    private DefaultDependencyArtifactDescriptor _dad;
+    private ConfigurationAware _confAware;
     private MDArtifact _artifact;
     private String _conf;
     private boolean _validate = true;
@@ -150,7 +155,8 @@
     private static final int DEP_ARTIFACT = 5;
     private static final int ARTIFACT_INCLUDE = 6;
     private static final int ARTIFACT_EXCLUDE = 7;
-    private static final int CONFLICT = 7;
+    private static final int CONFLICT = 8;
+    private static final int EXCLUDE = 9;
     private int _state = NONE;
 
     public Parser(ModuleDescriptorParser parser, IvySettings ivySettings, boolean validate) {
@@ -264,6 +270,9 @@
             } else if ("conflicts".equals(qName)) {
                 _state = CONFLICT;
                 checkConfigurations();
+            } else if ("exclude".equals(qName) && _state != DEP) {
+                _state = EXCLUDE;
+                checkConfigurations();
             } else if ("artifact".equals(qName)) {
                 if (_state == PUB) {
                     // this is a published artifact
@@ -297,9 +306,9 @@
                     addError("artifact tag found in invalid tag: "+_state);
                 }
             } else if ("include".equals(qName) && _state == DEP) {
-                addDependencyArtifactsIncludes(qName, attributes);
-            } else if ("exclude".equals(qName)) {
-                addDependencyArtifactsExcludes(qName, attributes);
+                addIncludeRule(qName, attributes);
+            } else if ("exclude".equals(qName) && _state == DEP) {
+                addExcludeRule(qName, attributes);
             } else if ("dependency".equals(qName)) {
                 String org = _ivy.substitute(attributes.getValue("org"));
                 if (org == null) { 
@@ -368,7 +377,7 @@
                 case DEP_ARTIFACT:
                 case ARTIFACT_INCLUDE:
                 case ARTIFACT_EXCLUDE:
-                    _dad.addConfiguration(conf);
+                    addConfiguration(conf);
                     break;
                 default:
                     if (_validate) {
@@ -409,6 +418,9 @@
                     return;
                 }
                 _md.addConflictManager(new ModuleId(org, mod), matcher, cm);
+            } else if ("rule".equals(qName) && _state == EXCLUDE) {
+                parseRule(qName, attributes);
+    			_md.addExcludeRule((ExcludeRule) _confAware);
             } else if ("include".equals(qName) && _state == CONF) {
                 URL url;
                 String fileName = _ivy.substitute(attributes.getValue("file"));
@@ -451,23 +463,26 @@
 
     private void addDependencyArtifacts(String tag, Attributes attributes) throws MalformedURLException {
         _state = DEP_ARTIFACT;
-        addDependencyArtifact(tag, attributes);
+        parseRule(tag, attributes);
     }
 
-    private void addDependencyArtifactsIncludes(String tag, Attributes attributes) throws MalformedURLException {
+    private void addIncludeRule(String tag, Attributes attributes) throws MalformedURLException {
         _state = ARTIFACT_INCLUDE;
-        addDependencyArtifact(tag, attributes);
+        parseRule(tag, attributes);
     }
 
-    private void addDependencyArtifactsExcludes(String tag, Attributes attributes) throws MalformedURLException {
+    private void addExcludeRule(String tag, Attributes attributes) throws MalformedURLException {
         _state = ARTIFACT_EXCLUDE;
-        addDependencyArtifact(tag, attributes);
+        parseRule(tag, attributes);
     }   
     
-    private void addDependencyArtifact(String tag, Attributes attributes) throws MalformedURLException {
+    private void parseRule(String tag, Attributes attributes) throws MalformedURLException {
         String name = _ivy.substitute(attributes.getValue("name"));
         if (name == null) {
-        	name = "artifact".equals(tag)?_dd.getDependencyId().getName() : PatternMatcher.ANY_EXPRESSION;
+        	name = _ivy.substitute(attributes.getValue("artifact"));
+        	if (name == null) {
+        		name = "artifact".equals(tag)?_dd.getDependencyId().getName() : PatternMatcher.ANY_EXPRESSION;
+        	}
         }
         String type = _ivy.substitute(attributes.getValue("type"));
         if (type == null) {
@@ -478,25 +493,25 @@
         if (_state == DEP_ARTIFACT) {
             String url = _ivy.substitute(attributes.getValue("url"));
             Map extraAtt = ExtendableItemHelper.getExtraAttributes(attributes, new String[] {"name", "type", "ext", "url", "conf"});
-            _dad = new DefaultDependencyArtifactDescriptor(_dd, name, type, ext, url==null?null:new URL(url), true, true, ExactPatternMatcher.INSTANCE, extraAtt);
+            _confAware = new DefaultDependencyArtifactDescriptor(name, type, ext, url==null?null:new URL(url), extraAtt);
         } else if (_state == ARTIFACT_INCLUDE) {
-        	PatternMatcher matcher = getDependencyArtifactMatcher(attributes.getValue("matcher"));
+        	PatternMatcher matcher = getPatternMatcher(attributes.getValue("matcher"));
             String org = _ivy.substitute(attributes.getValue("org"));
             org = org == null ? PatternMatcher.ANY_EXPRESSION : org;
             String module = _ivy.substitute(attributes.getValue("module"));
             module = module == null ? PatternMatcher.ANY_EXPRESSION : module;
             ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
             Map extraAtt = ExtendableItemHelper.getExtraAttributes(attributes, new String[] {"org", "module", "name", "type", "ext", "matcher", "conf"});
-            _dad = new DefaultDependencyArtifactDescriptor(_dd, aid, true, false, matcher, extraAtt);
-        } else {
-        	PatternMatcher matcher = getDependencyArtifactMatcher(attributes.getValue("matcher"));
+            _confAware = new DefaultIncludeRule(aid, matcher, extraAtt);
+        } else { // _state == ARTIFACT_EXCLUDE
+        	PatternMatcher matcher = getPatternMatcher(attributes.getValue("matcher"));
             String org = _ivy.substitute(attributes.getValue("org"));
             org = org == null ? PatternMatcher.ANY_EXPRESSION : org;
             String module = _ivy.substitute(attributes.getValue("module"));
             module = module == null ? PatternMatcher.ANY_EXPRESSION : module;
             ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
             Map extraAtt = ExtendableItemHelper.getExtraAttributes(attributes, new String[] {"org", "module", "name", "type", "ext", "matcher", "conf"});
-            _dad = new DefaultDependencyArtifactDescriptor(_dd, aid, false, false, matcher, extraAtt);
+            _confAware = new DefaultExcludeRule(aid, matcher, extraAtt);
         }
         String confs = _ivy.substitute(attributes.getValue("conf"));
         // only add confs if they are specified. if they aren't, endElement will handle this
@@ -509,12 +524,31 @@
                 conf = confs.split(",");
             }
             for (int i = 0; i < conf.length; i++) {
-                _dad.addConfiguration(conf[i].trim());
+				addConfiguration(conf[i].trim());
             }
         }
     }
 
-	private PatternMatcher getDependencyArtifactMatcher(String m) {
+	private void addConfiguration(String c) {
+		_confAware.addConfiguration(c);
+		if (_state == EXCLUDE) {
+			// we are adding a configuration to a module wide exclude rule
+			// we have nothing special to do here, the rule has already been added to the module descriptor
+		} else {
+			// we are currently adding a configuration to either an include, exclude or artifact element
+			// of a dependency. This means that we have to add this element to the corresponding conf
+			// of the current dependency descriptor
+			if (_confAware instanceof DependencyArtifactDescriptor) {
+				_dd.addDependencyArtifact(c, (DependencyArtifactDescriptor) _confAware);
+			} else if (_confAware instanceof IncludeRule) {
+				_dd.addIncludeRule(c, (IncludeRule) _confAware);
+			} else if (_confAware instanceof ExcludeRule) {
+				_dd.addExcludeRule(c, (ExcludeRule) _confAware);
+			}
+		}
+	}
+
+	private PatternMatcher getPatternMatcher(String m) {
 		String matcherName = _ivy.substitute(m);
         PatternMatcher matcher = matcherName == null ? _defaultMatcher : _ivy.getMatcher(matcherName);
         if (matcher == null) {
@@ -536,14 +570,25 @@
         		|| (_state == ARTIFACT_INCLUDE && "include".equals(qName))
         		|| (_state == ARTIFACT_EXCLUDE && "exclude".equals(qName))){
             _state = DEP;
-            if (_dad.getConfigurations().length == 0) {
+            if (_confAware.getConfigurations().length == 0) {
+                String[] confs = _md.getConfigurationsNames();
+                for (int i = 0; i < confs.length; i++) {
+                   addConfiguration(confs[i]);
+                }                
+            }
+            _confAware = null;
+        } else if (_state == EXCLUDE && "rule".equals(qName)){
+            if (_confAware.getConfigurations().length == 0) {
                 String[] confs = _md.getConfigurationsNames();
                 for (int i = 0; i < confs.length; i++) {
-                    _dad.addConfiguration(confs[i]);
+                   addConfiguration(confs[i]);
                 }                
             }
+            _confAware = null;
         } else if ("dependency".equals(qName) && _dd.getModuleConfigurations().length == 0) {
             parseDepsConfs(getDefaultConf(), _dd);
+        } else if ("dependencies".equals(qName)) {
+        	_state = NONE;
         }
     }
 

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java Tue Apr  3 10:45:54 2007
@@ -32,6 +32,8 @@
 import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ExcludeRule;
+import org.apache.ivy.core.module.descriptor.IncludeRule;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 
 
@@ -146,19 +148,15 @@
                         }
                     }
                     out.print("\"");
-                    DependencyArtifactDescriptor[] includes = dds[i].getAllDependencyArtifactsIncludes();
-                    if (includes.length > 0) {
+                    DependencyArtifactDescriptor[] depArtifacts = dds[i].getAllDependencyArtifacts();
+                    if (depArtifacts.length > 0) {
                         out.println(">");
-                        for (int j = 0; j < includes.length; j++) {
-                        	if (includes[j].isAssumePublished()) {
-                        		out.print("\t\t\t<artifact");
-                        	} else {
-                        		out.print("\t\t\t<include");
-                        	}
-                            out.print(" name=\""+includes[j].getName()+"\"");
-                            out.print(" type=\""+includes[j].getType()+"\"");
-                            out.print(" ext=\""+includes[j].getExt()+"\"");
-                            String[] dadconfs = includes[j].getConfigurations();
+                        for (int j = 0; j < depArtifacts.length; j++) {
+                        	out.print("\t\t\t<artifact");
+                            out.print(" name=\""+depArtifacts[j].getName()+"\"");
+                            out.print(" type=\""+depArtifacts[j].getType()+"\"");
+                            out.print(" ext=\""+depArtifacts[j].getExt()+"\"");
+                            String[] dadconfs = depArtifacts[j].getConfigurations();
                             if (!Arrays.asList(dadconfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                                 out.print(" conf=\"");
                                 for (int k = 0; k < dadconfs.length; k++) {
@@ -169,7 +167,7 @@
                                 }
                                 out.print("\"");
                             }
-                            Map extra = includes[j].getExtraAttributes();
+                            Map extra = depArtifacts[j].getExtraAttributes();
                             for (Iterator iter = extra.entrySet().iterator(); iter.hasNext();) {
 								Map.Entry entry = (Map.Entry) iter.next();
 	                            out.print(" "+entry.getKey()+"=\""+entry.getValue()+"\"");
@@ -177,24 +175,48 @@
                             out.println("/>");
                         }
                     }
-                    DependencyArtifactDescriptor[] excludes = dds[i].getAllDependencyArtifactsExcludes();
+                    IncludeRule[] includes = dds[i].getAllIncludeRules();
+                    if (includes.length > 0) {
+                        if (depArtifacts.length == 0) {
+                            out.println(">");
+                        }
+                        for (int j = 0; j < includes.length; j++) {
+                            out.print("\t\t\t<include");
+                            out.print(" name=\""+includes[j].getId().getName()+"\"");
+                            out.print(" type=\""+includes[j].getId().getType()+"\"");
+                            out.print(" ext=\""+includes[j].getId().getExt()+"\"");
+                            String[] ruleConfs = includes[j].getConfigurations();
+                            if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
+                                out.print(" conf=\"");
+                                for (int k = 0; k < ruleConfs.length; k++) {
+                                    out.print(ruleConfs[k]);
+                                    if (k+1 < ruleConfs.length) {
+                                        out.print(",");
+                                    }
+                                }
+                                out.print("\"");
+                            }
+                            out.println("/>");
+                        }
+                    }
+                    ExcludeRule[] excludes = dds[i].getAllExcludeRules();
                     if (excludes.length > 0) {
-                        if (includes.length == 0) {
+                        if (includes.length == 0 && depArtifacts.length == 0) {
                             out.println(">");
                         }
                         for (int j = 0; j < excludes.length; j++) {
                             out.print("\t\t\t<exclude");
                             out.print(" org=\""+excludes[j].getId().getModuleId().getOrganisation()+"\"");
                             out.print(" module=\""+excludes[j].getId().getModuleId().getName()+"\"");
-                            out.print(" name=\""+excludes[j].getName()+"\"");
-                            out.print(" type=\""+excludes[j].getType()+"\"");
-                            out.print(" ext=\""+excludes[j].getExt()+"\"");
-                            String[] dadconfs = excludes[j].getConfigurations();
-                            if (!Arrays.asList(dadconfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
+                            out.print(" name=\""+excludes[j].getId().getName()+"\"");
+                            out.print(" type=\""+excludes[j].getId().getType()+"\"");
+                            out.print(" ext=\""+excludes[j].getId().getExt()+"\"");
+                            String[] ruleConfs = excludes[j].getConfigurations();
+                            if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                                 out.print(" conf=\"");
-                                for (int k = 0; k < dadconfs.length; k++) {
-                                    out.print(dadconfs[k]);
-                                    if (k+1 < dadconfs.length) {
+                                for (int k = 0; k < ruleConfs.length; k++) {
+                                    out.print(ruleConfs[k]);
+                                    if (k+1 < ruleConfs.length) {
                                         out.print(",");
                                     }
                                 }
@@ -203,7 +225,7 @@
                             out.println("/>");
                         }
                     }
-                    if (includes.length + excludes.length == 0) {
+                    if (includes.length + excludes.length + depArtifacts.length == 0) {
                         out.println("/>");
                     } else {
                         out.println("\t\t</dependency>");

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd Tue Apr  3 10:45:54 2007
@@ -204,6 +204,30 @@
 				        </xs:sequence>
 			      </xs:complexType>
       		</xs:element>
+      		<xs:element name="exclude" minOccurs="0">
+			      <xs:complexType>
+				        <xs:sequence>
+				      		<xs:element name="rule" minOccurs="0" maxOccurs="unbounded">
+				            	<xs:complexType>
+							        <xs:sequence>
+							      		<xs:element name="conf" minOccurs="0" maxOccurs="unbounded">
+							            	<xs:complexType>
+									            <xs:attribute name="name" type="xs:string" use="required"/>
+							            	</xs:complexType>
+							      		</xs:element>
+							        </xs:sequence>
+						            <xs:attribute name="org" type="xs:string"/>
+						            <xs:attribute name="module" type="xs:string"/>
+						            <xs:attribute name="artifact" type="xs:string"/>
+						            <xs:attribute name="type" type="xs:string"/>
+						            <xs:attribute name="ext" type="xs:string"/>
+						            <xs:attribute name="conf" type="xs:string"/>
+						            <xs:attribute name="matcher" type="xs:string"/>
+				            	</xs:complexType>
+				      		</xs:element>
+				        </xs:sequence>
+			      </xs:complexType>
+      		</xs:element>
         </xs:sequence>
         <xs:attribute name="version" type="xs:string" use="required"/>
       </xs:complexType>

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java Tue Apr  3 10:45:54 2007
@@ -202,7 +202,7 @@
     				return null;
     			}
     			parser = XmlModuleDescriptorParser.getInstance();
-    			md = DefaultModuleDescriptor.newDefaultInstance(mrid, dd.getAllDependencyArtifactsIncludes());
+    			md = DefaultModuleDescriptor.newDefaultInstance(mrid, dd.getAllDependencyArtifacts());
     			ResolvedResource artifactRef = findFirstArtifactRef(md, dd, data);
     			checkInterrupted();
     			if (artifactRef == null) {

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?view=diff&rev=525217&r1=525216&r2=525217
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Tue Apr  3 10:45:54 2007
@@ -2416,6 +2416,20 @@
         assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
     }
     
+    public void testResolveExcludesModuleWide() throws Exception {
+        // mod2.6 depends on mod2.1 and excludes mod1.1 module wide
+        //      mod2.1 depends on mod1.1 which depends on mod1.2
+        ResolveReport report = _ivy.resolve(new File("test/repositories/1/org2/mod2.6/ivys/ivy-0.11.xml").toURL(),
+                getResolveOptions(new String[] {"*"}));
+        ModuleDescriptor md = report.getModuleDescriptor();
+        assertEquals(ModuleRevisionId.newInstance("org2", "mod2.6", "0.11"), md.getModuleRevisionId());
+        
+        assertFalse(_cacheManager.getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
+        assertFalse(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
+        assertFalse(_cacheManager.getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
+        assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").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").toURL(),