Author: xavier
Date: Wed Mar  7 13:02:25 2007
New Revision: 515753

URL: http://svn.apache.org/viewvc?view=rev&rev=515753
Log:
NEW: define artifacts not declared by the dependency module descriptor (IVY-419)
FIX: Ivy doesn't recognize maven2 classifiers (IVY-418)

Added:
    
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom
Modified:
    incubator/ivy/core/trunk/CHANGES.txt
    incubator/ivy/core/trunk/doc/doc/ivyfile/dependency-artifact.html
    
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/DependencyArtifactDescriptor.java
    
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.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/resolver/IBiblioResolver.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/m2/PomModuleDescriptorParserTest.java
    incubator/ivy/core/trunk/test/repositories/m2/ivyconf.xml

Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=515753&r1=515752&r2=515753
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Wed Mar  7 13:02:25 2007
@@ -7,6 +7,8 @@
 
    version in SVN
 =====================================
+- NEW: define artifacts not declared by the dependency module descriptor 
(IVY-419)
+
 - IMPROVE: Please typedef CacheResolver as "cache" for us (IVY-359)
 - IMPROVE: ivy:retrieve should be able to create symlinks (IVY-353) (thanks to 
John Williams)
 - IMPROVE: Ability to have multiple roots in the <ivy:buildfilelist> task 
(IVY-340) (thanks to Matt Inger)
@@ -14,6 +16,7 @@
 - IMPROVE: Add a unit test to verify that latest.integration accepts released 
modules (IVY-394) (thanks to Gilles Scokart)
 - IMPROVE: New "modules in use" section in console report at the end of 
resolve (IVY-373) (thanks to John Wiliams)
 
+- FIX: Ivy doesn't recognize maven2 classifiers (IVY-418)
 - FIX: Static revision replacement is not working when delivering an artifact 
with a dependency having extra attributes (IVY-415)
 - FIX: Static revision replacement is not working when delivering an artifact 
with a dependency on a branch (IVY-404)
 - FIX: latest-time conflict manager not working properly (IVY-407)

Modified: incubator/ivy/core/trunk/doc/doc/ivyfile/dependency-artifact.html
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/doc/doc/ivyfile/dependency-artifact.html?view=diff&rev=515753&r1=515752&r2=515753
==============================================================================
--- incubator/ivy/core/trunk/doc/doc/ivyfile/dependency-artifact.html (original)
+++ incubator/ivy/core/trunk/doc/doc/ivyfile/dependency-artifact.html Wed Mar  
7 13:02:25 2007
@@ -6,73 +6,85 @@
 </head>
 <body>
        <textarea id="xooki-source">
-<b>Tag:</b> artifact <b>Parent:</b> <a 
href="../../doc/ivyfile/dependency.html">dependency</a>
-
-This feature gives you more control on a dependency for which you do not 
control its ivy file. 
-It enables to specify the artifacts required, if the dependency has no ivy 
file. 
-
-Indeed, when a module has no ivy file, it is assumed that it publishes exactly 
one artifact having the same name as the module itself. But when this module 
publishes more artifacts, or simply does not respect the name rule, and if you 
cannot deliver an ivy file for it (because you do not control the repository, 
for instance - think about maven ibiblio repository, to give no name), then 
this feature let you specify the artifacts names you want to get.
-
-Each artifact specification can be given in the context of particular master 
configurations. By default, if no configuration is specified, artifacts 
specification apply to all master configurations. But you can specify that a 
specification applies only to one or several master configurations, using 
either inline or nested conf specification. In this case, do not forget that if 
you do not specify any specification for a particular configuration, then no 
specification will apply for this configuration and it will be resolved not 
taking into account any specification.
-
-For instance, imagine you have A, B & C master configurations. If you specify 
art1 in A & B and art2 in A, then C will not be specified at all, and will thus 
assume the default artifact. To prevent this, you have to specify a 
configuration mapping for the dependency, mapping only A & B to some or all 
dependency configurations.
-
-Example:
-<code type="xml">
-<dependency org="yourorg" name="yourmodule9" rev="9.1" conf="A,B->default">
-  <artifact name="art1" type="jar" conf="A,B"/>
-  <artifact name="art2" type="jar" conf="A"/>
-</dependency>  
-</code>
-
-<span class="since">since 1.4</span> It's possible to indicate the url at 
which the artifact can be found. This is not mandatory, and even not 
recommended with an enterprise repository. Note that Ivy will always look at 
the location where the artifact should be and only use th url if it cannot be 
found at the standard location in the repository.
-
-<h1>Attributes</h1>
-<table class="ivy-attributes">
-<thead>
-    <tr><th class="ivy-att">Attribute</th><th 
class="ivy-att-desc">Description</th><th class="ivy-att-req">Required</th></tr>
-</thead>
-<tbody>
-    <tr><td>name</td><td>the name of an artifact of the dependency module</td>
-        <td>Yes</td></tr>
-    <tr><td>type</td><td>the type of the artifact of the dependency module</td>
-        <td>Yes</td></tr>
-    <tr><td>ext</td><td>the extension of the artifact of the dependency 
module</td>
-        <td>No, defaults to type</td></tr>
-    <tr><td>conf</td><td>comma separated list of the master configurations in 
which this artifact should be included.
-    '*' wildcard can be used to designate all configurations of this 
module</td>
-        <td>No, defaults to '*', unless nested conf are specified</td></tr>
-    <tr><td>url</td><td>an url where this artifact can be found if it isn't 
present at the standard location in the repository <span class="since">since 
1.4</span></td>
-        <td>No, defaults to no url</td></tr>
-</tbody>
-</table>
-<h1>Child elements</h1>
-<table class="ivy-children">
-<thead>
-    <tr><th class="ivy-chld">Element</th><th 
class="ivy-chld-desc">Description</th><th 
class="ivy-chld-card">Cardinality</th></tr>
-</thead>
-<tbody>
-    <tr><td><a 
href="../../doc/ivyfile/dependency-artifact-conf.html">conf</a></td><td>configuration
 in which the artifact should be included</td>
-        <td>0..n</td></tr>
-</tbody>
-</table>
-<h1>Examples</h1>
-<code type="xml">
-<dependency org="foo" name="bar" rev="1.0">
-  <artifact name="baz" type="jar"/>
-</dependency>
-</code>
-Declares a dependency on module bar which only publish one artifact: baz.jar.
-
-<hr/>
-<code type="xml">
-<dependency org="foo" name="bar" rev="1.0">
-  <artifact name="baz" type="jar" 
url="http://www.acme.com/repository/bar/baz-1.0-acme.jar"/>
-</dependency>
-</code>
-Same as above, except that if the artifact is not found at its standard 
location, Ivy will use http://www.acme.com/repository/bar/baz-1.0-acme.jar to 
download it.
-
-       </textarea>
+<b>Tag:</b> artifact <b>Parent:</b> <a 
href="../../doc/ivyfile/dependency.html">dependency</a>
+
+This feature gives you more control on a dependency for which you do not 
control its ivy file. 
+It enables to specify the artifacts required, if the dependency has no ivy 
file. 
+
+Indeed, when a module has no ivy file, it is assumed that it publishes exactly 
one artifact having the same name as the module itself. But when this module 
publishes more artifacts, or simply does not respect the name rule, and if you 
cannot deliver an ivy file for it (because you do not control the repository, 
for instance - think about maven ibiblio repository, to give no name), then 
this feature let you specify the artifacts names you want to get.
+
+Each artifact specification can be given in the context of particular master 
configurations. By default, if no configuration is specified, artifacts 
specification apply to all master configurations. But you can specify that a 
specification applies only to one or several master configurations, using 
either inline or nested conf specification. In this case, do not forget that if 
you do not specify any specification for a particular configuration, then no 
specification will apply for this configuration and it will be resolved not 
taking into account any specification.
+
+For instance, imagine you have A, B & C master configurations. If you specify 
art1 in A & B and art2 in A, then C will not be specified at all, and will thus 
assume the default artifact. To prevent this, you have to specify a 
configuration mapping for the dependency, mapping only A & B to some or all 
dependency configurations.
+
+Example:
+<code type="xml">
+<dependency org="yourorg" name="yourmodule9" rev="9.1" conf="A,B->default">
+  <artifact name="art1" type="jar" conf="A,B"/>
+  <artifact name="art2" type="jar" conf="A"/>
+</dependency>  
+</code>
+
+<span class="since">since 1.4</span> It's possible to indicate the url at 
which the artifact can be found. This is not mandatory, and even not 
recommended with an enterprise repository. Note that Ivy will always look at 
the location where the artifact should be and only use the url if it cannot be 
found at the standard location in the repository.
+
+<span class="since">since 1.5</span> This feature can also be used for modules 
having their own module descriptor, but which doesn't declare an artifact you 
know that is published. To use this behavior, set the <i>assumePublished</i> 
attribute to true. Note that in this case artifacts declared to be published by 
the dependency will be ignored, so do not forget to include all artifacts you 
want.
+
+<h1>Attributes</h1>
+<table class="ivy-attributes">
+<thead>
+    <tr><th class="ivy-att">Attribute</th><th 
class="ivy-att-desc">Description</th><th class="ivy-att-req">Required</th></tr>
+</thead>
+<tbody>
+    <tr><td>name</td><td>the name of an artifact of the dependency module</td>
+        <td>Yes</td></tr>
+    <tr><td>type</td><td>the type of the artifact of the dependency module</td>
+        <td>Yes</td></tr>
+    <tr><td>ext</td><td>the extension of the artifact of the dependency 
module</td>
+        <td>No, defaults to type</td></tr>
+    <tr><td>conf</td><td>comma separated list of the master configurations in 
which this artifact should be included.
+    '*' wildcard can be used to designate all configurations of this 
module</td>
+        <td>No, defaults to '*', unless nested conf are specified</td></tr>
+    <tr><td>assumePublished</td><td>true if this artifact should be assumed to 
be published by the dependency even if it has its own module descriptor <span 
class="since">since 1.5</span></td>
+        <td>No, defaults to false</td></tr>
+    <tr><td>url</td><td>an url where this artifact can be found if it isn't 
present at the standard location in the repository <span class="since">since 
1.4</span></td>
+        <td>No, defaults to no url</td></tr>
+</tbody>
+</table>
+<h1>Child elements</h1>
+<table class="ivy-children">
+<thead>
+    <tr><th class="ivy-chld">Element</th><th 
class="ivy-chld-desc">Description</th><th 
class="ivy-chld-card">Cardinality</th></tr>
+</thead>
+<tbody>
+    <tr><td><a 
href="../../doc/ivyfile/dependency-artifact-conf.html">conf</a></td><td>configuration
 in which the artifact should be included</td>
+        <td>0..n</td></tr>
+</tbody>
+</table>
+<h1>Examples</h1>
+<code type="xml">
+<dependency org="foo" name="bar" rev="1.0">
+  <artifact name="baz" type="jar"/>
+</dependency>
+</code>
+Declares a dependency on module bar which only publish one artifact: baz.jar.
+
+<hr/>
+<code type="xml">
+<dependency org="foo" name="bar" rev="1.0">
+  <artifact name="baz" type="jar" 
url="http://www.acme.com/repository/bar/baz-1.0-acme.jar"/>
+</dependency>
+</code>
+Same as above, except that if the artifact is not found at its standard 
location, Ivy will use http://www.acme.com/repository/bar/baz-1.0-acme.jar to 
download it.
+
+<hr/>
+<code type="xml">
+<dependency org="foo" name="bar" rev="1.0">
+  <include name="*"/>
+  <artifact name="baz" type="source" ext="jar" assumePublished="true"/>
+</dependency>
+</code>
+Declares a dependency on module bar for which all artifacts declared will be 
used (thanks to the include tag) plus an artifact baz of type source and ext 
jar (which is not declared in module bar module descriptor).
+</textarea>
 <script type="text/javascript">xooki.postProcess();</script>
 </body>
 </html>

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=515753&r1=515752&r2=515753
==============================================================================
--- 
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
 Wed Mar  7 13:02:25 2007
@@ -20,25 +20,28 @@
 import java.net.URL;
 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;
 
 
-public class DefaultDependencyArtifactDescriptor implements 
DependencyArtifactDescriptor {
+public class DefaultDependencyArtifactDescriptor extends 
UnmodifiableExtendableItem
+       implements DependencyArtifactDescriptor {
 
     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, matcher);
+               this(dd, name, type, ext, null, includes, false, matcher, null);
        }
     /**
      * @param dd
@@ -47,7 +50,8 @@
      * @param url 
      */
     public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd,
-            String name, String type, String ext, URL url, boolean includes, 
PatternMatcher matcher) {
+            String name, String type, String ext, URL url, boolean includes, 
boolean assumePublished, PatternMatcher matcher, Map extraAttributes) {
+       super(null, extraAttributes);
         if (dd == null) {
             throw new NullPointerException("dependency descriptor must not be 
null");
         }
@@ -62,9 +66,12 @@
         _includes = includes;
         _url = url;
         _patternMatcher = matcher;
+        _assumePublished = assumePublished;
+        initStandardAttributes();
     }
-    
-    public DefaultDependencyArtifactDescriptor(DefaultDependencyDescriptor dd, 
ArtifactId aid, boolean includes, PatternMatcher matcher) {
+
+    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");
         }
@@ -72,8 +79,22 @@
         _id = aid;
         _includes = includes;
         _patternMatcher = matcher;
+        _assumePublished = assumePublished;
+        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("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) {
         if (!(obj instanceof DependencyArtifactDescriptor)) {
             return false;
@@ -133,5 +154,8 @@
 
        public String toString() {
                return 
(_includes?"I":"E")+":"+_id+"("+_confs+")"+(_url==null?"":_url.toString());
+       }
+       public boolean isAssumePublished() {
+               return _assumePublished;
        }
 }

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=515753&r1=515752&r2=515753
==============================================================================
--- 
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
 Wed Mar  7 13:02:25 2007
@@ -21,6 +21,7 @@
 
 import org.apache.ivy.core.module.id.ArtifactId;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
+import org.apache.ivy.util.extendable.ExtendableItem;
 
 
 /**
@@ -29,7 +30,7 @@
  * It is used to resctrict the artifacts asked for a dependency, or describe 
them
  * when there is no ivy file.
  */
-public interface DependencyArtifactDescriptor {
+public interface DependencyArtifactDescriptor extends ExtendableItem {
     /**
      * Returns the dependency descriptor in which this artifact is asked
      * @return
@@ -72,4 +73,14 @@
      * @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/id/ArtifactRevisionId.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java?view=diff&rev=515753&r1=515752&r2=515753
==============================================================================
--- 
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
 (original)
+++ 
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
 Wed Mar  7 13:02:25 2007
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.core.module.id;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.ivy.core.IvyPatternHelper;
@@ -32,6 +33,13 @@
     }
     
     public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String 
name, String type, String ext, Map extraAttributes) {
+       // we inject module extra attributes as extra attributes for the 
artifacts too
+       if (extraAttributes == null) {
+               extraAttributes = mrid.getExtraAttributes();
+       } else {
+               extraAttributes = new HashMap(extraAttributes);
+               extraAttributes.putAll(mrid.getExtraAttributes());
+       }
         return new ArtifactRevisionId(new ArtifactId(mrid.getModuleId(), name, 
type, ext), mrid, extraAttributes);
     }
     

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=515753&r1=515752&r2=515753
==============================================================================
--- 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 
Wed Mar  7 13:02:25 2007
@@ -735,7 +735,7 @@
             // at download time
             for (Iterator it = includes.iterator(); it.hasNext();) {
                 DependencyArtifactDescriptor dad = 
(DependencyArtifactDescriptor)it.next();
-                artifacts.add(new MDArtifact(_md, dad.getName(), 
dad.getType(), dad.getExt(), dad.getUrl(), null));
+                artifacts.add(new MDArtifact(_md, dad.getName(), 
dad.getType(), dad.getExt(), dad.getUrl(), dad.getExtraAttributes()));
             }
         } else {
             if (includes == null || includes.isEmpty()) {
@@ -761,14 +761,18 @@
                 // now we can keep only listed ones
                 for (Iterator it = includes.iterator(); it.hasNext();) {
                     DependencyArtifactDescriptor dad = 
(DependencyArtifactDescriptor)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(); 
+                    if (dad.isAssumePublished()) {
+                        artifacts.add(new MDArtifact(_md, dad.getName(), 
dad.getType(), dad.getExt(), dad.getUrl(), dad.getExtraAttributes()));
                     } else {
-                        Message.debug(this+" in "+rootModuleConf+": including 
"+arts);
-                        artifacts.addAll(arts);
+                       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);
+                       }
                     }
                 }
             }

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=515753&r1=515752&r2=515753
==============================================================================
--- 
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
 Wed Mar  7 13:02:25 2007
@@ -83,6 +83,7 @@
         private String _module;
         private String _revision;
         private String _scope;
+        private String _classifier;
         private boolean _optional = false;
         private List _exclusions = new ArrayList();
         private DefaultDependencyDescriptor _dd;
@@ -158,11 +159,43 @@
                 }
                 parseDepsConfs(mapping, _dd);
                 
+                if (_classifier != null) {
+                       // we deal with classifiers by setting an extra 
attribute and forcing the dependency to assume such an artifact is published
+                    Map extraAtt = new HashMap();
+                    extraAtt.put("classifier", _classifier);
+                    String[] confs = _dd.getModuleConfigurations();
+                    for (int i = 0; i < confs.length; i++) {
+                       _dd.addDependencyArtifactIncludes(
+                                       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,
+                                                       extraAtt));
+                    }
+                }
                 for (Iterator iter = _exclusions.iterator(); iter.hasNext();) {
                     ModuleId mid = (ModuleId)iter.next();
                     String[] confs = _dd.getModuleConfigurations();
                     for (int i = 0; i < confs.length; i++) {
-                        _dd.addDependencyArtifactExcludes(confs[i], new 
DefaultDependencyArtifactDescriptor(_dd, new ArtifactId(mid, 
PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, 
PatternMatcher.ANY_EXPRESSION), false, ExactPatternMatcher.INSTANCE));
+                        _dd.addDependencyArtifactExcludes(confs[i], 
+                                       new DefaultDependencyArtifactDescriptor(
+                                                       _dd, 
+                                                       new ArtifactId(
+                                                                       mid, 
+                                                                       
PatternMatcher.ANY_EXPRESSION, 
+                                                                       
PatternMatcher.ANY_EXPRESSION, 
+                                                                       
PatternMatcher.ANY_EXPRESSION), 
+                                                               false, 
+                                                               false, 
+                                                               
ExactPatternMatcher.INSTANCE,
+                                                               null));
                     }
                 }
                 _md.addDependency(_dd);
@@ -177,6 +210,7 @@
                 _module = null;
                 _revision = null;
                 _scope = null;
+                _classifier = null;
                 _optional = false;
                 _exclusions.clear();
             }
@@ -207,6 +241,8 @@
                     _revision = txt;
                 } else if (_scope == null && context.endsWith("scope")) {
                     _scope = txt;
+                } else if (_classifier == null && 
context.endsWith("dependency/classifier")) {
+                       _classifier = txt;
                 }
             }
         }

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=515753&r1=515752&r2=515753
==============================================================================
--- 
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
 Wed Mar  7 13:02:25 2007
@@ -26,6 +26,7 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.parsers.ParserConfigurationException;
 
@@ -479,14 +480,18 @@
         }
         if (includes) {
             String url = _ivy.substitute(attributes.getValue("url"));
-            _dad = new DefaultDependencyArtifactDescriptor(_dd, name, type, 
ext, url==null?null:new URL(url), includes, matcher);
+            Map extraAtt = ExtendableItemHelper.getExtraAttributes(attributes, 
new String[] {"name", "type", "ext", "matcher", "assumePublished", "url"});
+            String assumePublishedStr = 
_ivy.substitute(attributes.getValue("assumePublished"));
+            boolean assumePublished = assumePublishedStr != null && 
Boolean.valueOf(assumePublishedStr).booleanValue();
+            _dad = new DefaultDependencyArtifactDescriptor(_dd, name, type, 
ext, url==null?null:new URL(url), includes, assumePublished, matcher, extraAtt);
         } else {
             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);
-            _dad = new DefaultDependencyArtifactDescriptor(_dd, aid, includes, 
matcher);
+            Map extraAtt = ExtendableItemHelper.getExtraAttributes(attributes, 
new String[] {"org", "module", "name", "type", "ext", "matcher", 
"assumePublished"});
+            _dad = new DefaultDependencyArtifactDescriptor(_dd, aid, includes, 
false, matcher, extraAtt);
         }
         String confs = _ivy.substitute(attributes.getValue("conf"));
         // only add confs if they are specified. if they aren't, endElement 
will handle this

Modified: 
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java?view=diff&rev=515753&r1=515752&r2=515753
==============================================================================
--- 
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
 (original)
+++ 
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
 Wed Mar  7 13:02:25 2007
@@ -79,7 +79,7 @@
         super.setM2compatible(m2compatible);
         if (m2compatible) {
             _root = "http://www.ibiblio.org/maven2/";;
-            _pattern = 
"[organisation]/[module]/[revision]/[artifact]-[revision].[ext]";
+            _pattern = 
"[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]";
             updateWholePattern();
         }
     }

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=515753&r1=515752&r2=515753
==============================================================================
--- 
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 
Wed Mar  7 13:02:25 2007
@@ -2463,6 +2463,26 @@
         assertTrue(TestHelper.getArchiveFileInCache(ivy, _cache, "org.apache", 
"test", "1.0", "test", "jar", "jar").exists());
     }
     
+    public void testResolveMaven2Classifiers() throws Exception {
+       // test case for IVY-418
+        // test-classifier depends on test-classified with classifier asl
+        Ivy ivy = new Ivy();
+        ivy.configure(new File("test/repositories/m2/ivyconf.xml"));
+        ResolveReport report = ivy.resolve(new 
File("test/repositories/m2/org/apache/test-classifier/1.0/test-classifier-1.0.pom").toURL(),
+                getResolveOptions(new String[] {"*"}));
+        assertNotNull(report);
+        ModuleDescriptor md = report.getModuleDescriptor();
+        assertNotNull(md);
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", 
"test-classifier", "1.0");
+        assertEquals(mrid, md.getModuleRevisionId());
+        
+        
assertTrue(ivy.getCacheManager(_cache).getResolvedIvyFileInCache(mrid).exists());
+        
+        // dependencies
+        
assertTrue(ivy.getCacheManager(_cache).getIvyFileInCache(ModuleRevisionId.newInstance("org.apache",
 "test-classified", "1.0")).exists());
+        assertTrue(TestHelper.getArchiveFileInCache(ivy, _cache, "org.apache", 
"test-classified", "1.0", "test-classified", "jar", "jar").exists());
+    }
+    
     public void testNamespaceMapping() throws Exception {
         // the dependency is in another namespace
         Ivy ivy = new Ivy();

Modified: 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java?view=diff&rev=515753&r1=515752&r2=515753
==============================================================================
--- 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
 (original)
+++ 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
 Wed Mar  7 13:02:25 2007
@@ -18,7 +18,9 @@
 package org.apache.ivy.plugins.parser.m2;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 
 import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
@@ -100,6 +102,22 @@
         assertNotNull(dds);
         assertEquals(1, dds.length);
         assertEquals(ModuleRevisionId.newInstance("commons-logging", 
"commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
+    }
+    
+    public void testDependenciesWithClassifier() throws Exception {
+        ModuleDescriptor md = 
PomModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), 
getClass().getResource("test-dependencies-with-classifier.pom"), false);
+        assertNotNull(md);
+        
+        assertEquals(ModuleRevisionId.newInstance("org.apache", "test", 
"1.0"), md.getModuleRevisionId());
+        
+        DependencyDescriptor[] dds = md.getDependencies();
+        assertNotNull(dds);
+        assertEquals(1, dds.length);
+        assertEquals(ModuleRevisionId.newInstance("commons-logging", 
"commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
+        Map extraAtt = new HashMap();
+        extraAtt.put("classifier", "asl");
+        assertEquals(1, dds[0].getAllDependencyArtifactsIncludes().length);
+        assertEquals(extraAtt, 
dds[0].getAllDependencyArtifactsIncludes()[0].getExtraAttributes());
     }
     
     // IVY-392

Added: 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom?view=auto&rev=515753
==============================================================================
--- 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom
 (added)
+++ 
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom
 Wed Mar  7 13:02:25 2007
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache</groupId>
+  <artifactId>test</artifactId>
+  <name>Test Module for Ivy M2 parsing</name>
+  <version>1.0</version>
+  <url>http://ivy.jayasoft.org/</url>
+  <organization>
+    <name>Jayasoft</name>
+    <url>http://www.jayasoft.org/</url>
+  </organization>
+  <dependencies>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.4</version>
+      <classifier>asl</classifier>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Modified: incubator/ivy/core/trunk/test/repositories/m2/ivyconf.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/m2/ivyconf.xml?view=diff&rev=515753&r1=515752&r2=515753
==============================================================================
--- incubator/ivy/core/trunk/test/repositories/m2/ivyconf.xml (original)
+++ incubator/ivy/core/trunk/test/repositories/m2/ivyconf.xml Wed Mar  7 
13:02:25 2007
@@ -3,7 +3,7 @@
        <resolvers>
                <filesystem name="m2" m2compatible="true">
                        <ivy 
pattern="${ivy.conf.dir}/[organisation]/[module]/[revision]/[module]-[revision].pom"/>
-                       <artifact 
pattern="${ivy.conf.dir}/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
+                       <artifact 
pattern="${ivy.conf.dir}/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
                </filesystem>
        </resolvers>
 </ivyconf>


Reply via email to