You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2008/09/14 21:08:30 UTC

svn commit: r695267 - in /ant/ivy/core/trunk: CHANGES.txt doc/resolver/dual.html src/java/org/apache/ivy/plugins/resolver/DualResolver.java

Author: maartenc
Date: Sun Sep 14 12:08:29 2008
New Revision: 695267

URL: http://svn.apache.org/viewvc?rev=695267&view=rev
Log:
IMPROVEMENT: DualResolver should also provide setDescriptor method instead of setAllownomd, which is deprecated for the other resolvers (IVY-903)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/resolver/dual.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=695267&r1=695266&r2=695267&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sun Sep 14 12:08:29 2008
@@ -84,6 +84,7 @@
 - NEW: Add transitive dependency version and branch override mechanism (IVY-784)
 - NEW: Add new packager resolver (IVY-829) (thanks to Archie Cobbs)
 
+- IMPROVEMENT: DualResolver should also provide setDescriptor method instead of setAllownomd, which is deprecated for the other resolvers (IVY-903)
 - IMPROVEMENT: Parse license information in poms (IVY-892)
 - IMPROVEMENT: Change 'alwaysUseExactRevision' default value to false (IVY-891)
 - IMPROVEMENT: Better and more homogeneous relative paths handling (IVY-387) 

Modified: ant/ivy/core/trunk/doc/resolver/dual.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/resolver/dual.html?rev=695267&r1=695266&r2=695267&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/resolver/dual.html (original)
+++ ant/ivy/core/trunk/doc/resolver/dual.html Sun Sep 14 12:08:29 2008
@@ -34,16 +34,7 @@
 
 <h1>Attributes</h1>
 This resolver shares the <a href="../settings/resolvers.html#common">common attributes</a> of composite resolvers.
-<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>allownomd</td><td>true if the absence of module descriptor (usually an ivy file) is authorised for this resolver, false to refuse modules without module descriptor <span class="since">since 1.4</span></td>
-        <td>No, defaults to true</td>
-    </tr>
-</tbody>
-</table>
+
 <h1>Child elements</h1>
 <table class="ivy-children">
 <thead>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java?rev=695267&r1=695266&r2=695267&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java Sun Sep 14 12:08:29 2008
@@ -20,6 +20,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.text.ParseException;
+import java.util.Arrays;
 
 import org.apache.ivy.core.cache.ArtifactOrigin;
 import org.apache.ivy.core.module.descriptor.Artifact;
@@ -44,6 +45,9 @@
  * first resolver added if the ivy resolver, the second is the artifact one.
  */
 public class DualResolver extends AbstractResolver {
+    public static final String DESCRIPTOR_OPTIONAL = "optional";
+    public static final String DESCRIPTOR_REQUIRED = "required";
+
     private DependencyResolver ivyResolver;
 
     private DependencyResolver artifactResolver;
@@ -188,7 +192,29 @@
     }
 
     public void setAllownomd(boolean allownomd) {
+        Message.deprecated(
+            "allownomd is deprecated, please use descriptor=\"" 
+            + (allownomd ? DESCRIPTOR_OPTIONAL : DESCRIPTOR_REQUIRED) + "\" instead");
         this.allownomd = allownomd;
     }
 
+    /**
+     * Sets the module descriptor presence rule.
+     * Should be one of {@link #DESCRIPTOR_REQUIRED} or {@link #DESCRIPTOR_OPTIONAL}.
+     *  
+     * @param descriptorRule the descriptor rule to use with this resolver.
+     */
+    public void setDescriptor(String descriptorRule) {
+        if (DESCRIPTOR_REQUIRED.equals(descriptorRule)) {
+          allownomd = false;  
+        } else if (DESCRIPTOR_OPTIONAL.equals(descriptorRule)) {
+          allownomd = true;  
+        } else {
+            throw new IllegalArgumentException(
+                "unknown descriptor rule '" + descriptorRule 
+                + "'. Allowed rules are: " 
+                + Arrays.asList(new String[] {DESCRIPTOR_REQUIRED, DESCRIPTOR_OPTIONAL}));
+        }
+    }
+
 }