You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by "Andreas Axelsson (JIRA)" <ji...@apache.org> on 2009/11/20 12:57:40 UTC

[jira] Created: (IVY-1142) ivy:retrieve sync="true" fails if first variable is optional

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.


[jira] Updated: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Andreas Axelsson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Axelsson updated IVY-1142:
----------------------------------

    Attachment: IVY-1142.patch

The patch from the description

> ivy:retrieve sync="true" does nothing 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
>         Attachments: IVY-1142.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.


[jira] Updated: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maarten Coene updated IVY-1142:
-------------------------------

    Fix Version/s: 2.2.0-RC1
                       (was: trunk)

> ivy:retrieve sync="true" does nothing 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
>            Assignee: Maarten Coene
>             Fix For: 2.2.0-RC1
>
>         Attachments: IVY-1142.patch
>
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.
> {noformat}
> 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 {
> {noformat}

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


[jira] Updated: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Andreas Axelsson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Axelsson updated IVY-1142:
----------------------------------

    Comment: was deleted

(was: Absolutely, is the patch format ok? It's the default mercurial (hg diff)
output format.

Cheers,
/axl


)

> ivy:retrieve sync="true" does nothing 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
>         Attachments: IVY-1142.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.


[jira] Updated: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Andreas Axelsson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Axelsson updated IVY-1142:
----------------------------------

    Description: 
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 the first '[', but in the pattern above it needs to check for the first '('.

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 {


  was:
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 {


        Summary: ivy:retrieve sync="true" does nothing if first variable is optional  (was: ivy:retrieve sync="true" fails if first variable is optional)

improved summary and description

> ivy:retrieve sync="true" does nothing 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
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.


[jira] Updated: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maarten Coene updated IVY-1142:
-------------------------------

           Description: 
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 the first '[', but in the pattern above it needs to check for the first '('.

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.

{noformat}
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 {
{noformat}

  was:
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 the first '[', but in the pattern above it needs to check for the first '('.

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 {


              Assignee: Maarten Coene
    Remaining Estimate:     (was: 1h)
     Original Estimate:     (was: 1h)

> ivy:retrieve sync="true" does nothing 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
>            Assignee: Maarten Coene
>         Attachments: IVY-1142.patch
>
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.
> {noformat}
> 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 {
> {noformat}

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


[jira] Resolved: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maarten Coene resolved IVY-1142.
--------------------------------

       Resolution: Fixed
    Fix Version/s: trunk

I've updated IvyPatternHelper so your problem should be fixed.
Could you give it a try?

thanks!
Maarten

> ivy:retrieve sync="true" does nothing 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
>            Assignee: Maarten Coene
>             Fix For: trunk
>
>         Attachments: IVY-1142.patch
>
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.
> {noformat}
> 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 {
> {noformat}

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


[jira] Commented: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12780580#action_12780580 ] 

Maarten Coene commented on IVY-1142:
------------------------------------

Could you attach your patch as an attachment and check the "grant license to ASF" option?

Thanks,
Maarten

> ivy:retrieve sync="true" does nothing 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
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.


[jira] Commented: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Andreas Axelsson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12781331#action_12781331 ] 

Andreas Axelsson commented on IVY-1142:
---------------------------------------

Thanks, it's working fine!

I see that your code avoids stripping at left parenthesis when there are no variables in the path, which was a better solution than mine. Perhaps it should be detected only if the brackets are actually enclosed by the parenthesis, but it'd have to be checked against how the pattern substitution code deals with the same case I guess. Not that using () in foldernames is a best practice IMHO, but someone might want it.

The following root will be correct now: ([optional] being empty)
/foo/([optional]/)bar -> /foo/
/foo/[module]/bar -> /foo/
/foo/(subdir)/bar -> /foo/(subdir)/bar

This won't:
/(foo)/[module]/bar -> /


> ivy:retrieve sync="true" does nothing 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
>            Assignee: Maarten Coene
>             Fix For: trunk
>
>         Attachments: IVY-1142.patch
>
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.
> {noformat}
> 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 {
> {noformat}

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


[jira] Commented: (IVY-1142) ivy:retrieve sync="true" does nothing if first variable is optional

Posted by "Andreas Axelsson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-1142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12780590#action_12780590 ] 

Andreas Axelsson commented on IVY-1142:
---------------------------------------

Absolutely, is the patch format ok? It's the default mercurial (hg diff)
output format.

Cheers,
/axl




> ivy:retrieve sync="true" does nothing 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
>         Attachments: IVY-1142.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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 the first '[', but in the pattern above it needs to check for the first '('.
> 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.