ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r738276 - in /ant/ivy/core/trunk: CHANGES.txt doc/use/buildnumber.html src/java/org/apache/ivy/ant/IvyBuildNumber.java
Date Tue, 27 Jan 2009 22:17:26 GMT
Author: maartenc
Date: Tue Jan 27 22:17:26 2009
New Revision: 738276

URL: http://svn.apache.org/viewvc?rev=738276&view=rev
Log:
IMPROVEMENT: resolver attribute for buildnumber task (IVY-1019) (thanks to Martin Eigenbrodt)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/use/buildnumber.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=738276&r1=738275&r2=738276&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Jan 27 22:17:26 2009
@@ -85,6 +85,7 @@
 	
    trunk
 =====================================
+- IMPROVEMENT: resolver attribute for buildnumber task (IVY-1019) (thanks to Martin Eigenbrodt)
 - IMPROVEMENT: add refresh parameter to post resolve tasks (IVY-1017)
 - IMPROVEMENT: Remove excessive HEAD requests for URL repository (IVY-996)
 - IMPROVEMENT: add -version option on command line (IVY-1014)

Modified: ant/ivy/core/trunk/doc/use/buildnumber.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/buildnumber.html?rev=738276&r1=738275&r2=738276&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/buildnumber.html (original)
+++ ant/ivy/core/trunk/doc/use/buildnumber.html Tue Jan 27 22:17:26 2009
@@ -77,7 +77,9 @@
         <td>No, defaults to '.'</td></tr>
     <tr><td>prefix</td><td>the prefix to use for the property names
set (will be <i>prefix</i>.revision, <i>prefix</i>.new.revision, ...)</td>
         <td>No, defaults to ivy</td></tr>
-    <tr><td>settingsRef</td><td><span class="since">(since
2.0)</span> A reference to the ivy settings that must be used by this task</td><td>No,
'ivy.instance' is taken by default.</td></tr>
+    <tr><td>settingsRef</td><td>A reference to the ivy settings that
must be used by this task <span class="since">(since 2.0)</span>.</td><td>No,
'ivy.instance' is taken by default.</td></tr>
+    <tr><td>resolver</td><td>the name of the resolver to use for
build number calculation <span class="since">(since 2.1)</span></td>
+        <td>No, all available resolvers will be used by default.</td></tr>
 </tbody>
 </table>
 <h1>Examples</h1>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java?rev=738276&r1=738275&r2=738276&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java Tue Jan 27 22:17:26
2009
@@ -32,6 +32,7 @@
 import org.apache.ivy.plugins.matcher.ExactPatternMatcher;
 import org.apache.ivy.plugins.matcher.Matcher;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.plugins.version.VersionMatcher;
 import org.apache.tools.ant.BuildException;
 
@@ -74,6 +75,8 @@
 
     private String defaultBuildNumber = "0";
 
+    private String resolver = null;
+
     public String getModule() {
         return module;
     }
@@ -114,6 +117,14 @@
         defaultValue = default1;
     }
 
+    public String getResolver() {
+        return resolver;
+    }
+
+    public void setResolver(String resolver) {
+        this.resolver = resolver;
+    }
+
     public String getPrefix() {
         return prefix;
     }
@@ -148,25 +159,37 @@
         }
         
         SearchEngine searcher = new SearchEngine(settings);
-        ModuleRevisionId[] revisions = searcher.listModules(ModuleRevisionId.newInstance(organisation,
-            module, branch, ".*"), new PatternMatcher() {
-                private PatternMatcher exact = new ExactPatternMatcher();
-                private PatternMatcher regexp = new ExactOrRegexpPatternMatcher();
-            
-                public Matcher getMatcher(String expression) {
-                    if ((expression == organisation)
-                            || (expression == module)
-                            || (expression == branch)) {
-                        return exact.getMatcher(expression);
-                    }
-                    return regexp.getMatcher(expression);
+        
+        PatternMatcher patternMatcher = new PatternMatcher() {
+            private PatternMatcher exact = new ExactPatternMatcher();
+            private PatternMatcher regexp = new ExactOrRegexpPatternMatcher();
+        
+            public Matcher getMatcher(String expression) {
+                if ((expression == organisation)
+                        || (expression == module)
+                        || (expression == branch)) {
+                    return exact.getMatcher(expression);
                 }
+                return regexp.getMatcher(expression);
+            }
+
+            public String getName() {
+                return "buildnumber-matcher";
+            }
+        };
+        ModuleRevisionId[] revisions;
+        if (resolver == null) {
+            revisions = searcher.listModules(ModuleRevisionId.newInstance(organisation,
+                module, branch, ".*"), patternMatcher);
+        } else {
+            DependencyResolver depResolver = settings.getResolver(resolver);
+            if (depResolver == null) {
+                throw new BuildException("Unknown resolver: " + resolver);
+            }
+            revisions = searcher.listModules(depResolver, ModuleRevisionId.newInstance(organisation,
+                module, branch, ".*"), patternMatcher);
+        }
 
-                public String getName() {
-                    return "buildnumber-matcher";
-                }
-            });
-        
         ArtifactInfo[] infos = new ArtifactInfo[revisions.length];
         for (int i = 0; i < revisions.length; i++) {
             infos[i] = new ResolvedModuleRevisionArtifactInfo(revisions[i]);



Mime
View raw message