ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Axelsson (JIRA)" <j...@apache.org>
Subject [jira] Created: (IVY-1142) ivy:retrieve sync="true" fails if first variable is optional
Date Fri, 20 Nov 2009 11:57:40 GMT
ivy:retrieve sync="true" fails if first variable is optional
------------------------------------------------------------

                 Key: IVY-1142
                 URL: https://issues.apache.org/jira/browse/IVY-1142
             Project: Ivy
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.1.0
         Environment: Not relevant
            Reporter: Andreas Axelsson


if the ivy.retrieve.pattern contains an optional parameter as the first parameter, the sync
feature of ivy:retrieve will get a path with a trailing '(' causing it to find nothing to
sync, leaving old files still in the retrieve path.

Example:
ivy.retrieve.pattern = lib/([type]/)/[artifact].[ext]
sync will try to match orphaned files against lib/( which obviously contains nothing.

The problem is in IvyPatternHelper.java getTokenRoot(), which only checks for '['.

I could see that nothing but the Resolver uses this function so it looks like it'll be pretty
safe to just fix the check. I've attached a suggested fix below. I rarely touch java, so there
might be simpler ways to do it, but at least it works.

diff -r 616a4e764dd1 src/java/org/apache/ivy/core/IvyPatternHelper.java
--- a/src/java/org/apache/ivy/core/IvyPatternHelper.java        Fri Nov 20 11:38:53 2009 +0100
+++ b/src/java/org/apache/ivy/core/IvyPatternHelper.java        Fri Nov 20 12:54:27 2009 +0100
@@ -472,7 +472,15 @@
     }

     public static String getTokenRoot(String pattern) {
-        int index = pattern.indexOf('[');
+        int[] delimiters = {'[', '('};
+        for (int index = 0; index < delimiters.length; ++index) {
+            pattern = getTokenRoot(pattern, delimiters[index]);
+        }
+        return pattern;
+    }
+
+    private static String getTokenRoot(String pattern, int delimiter) {
+        int index = pattern.indexOf(delimiter);
         if (index == -1) {
             return pattern;
         } else {


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message