Maven Antrun Plugin
  1. Maven Antrun Plugin
  2. MANTRUN-36

Esccape property replacement inside quote

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.1
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      4

      Description

      The propoerties placed not alone inside quotes are not correctly interpreted. For example :
      <property name="myProp" value="OK" />
      <echo message="alone in quote :"/>
      <echo message="$

      {myProp}"/>
      <echo>not alone in text ${myProp}

      .</echo>
      <echo message="not alone in quote $

      {myProp}

      ."></echo>
      <fail unless="myProp"/>

      Succeed and print :
      [echo] alone in quote :
      [echo] OK
      [echo] not alone in text OK.
      [echo] not alone in quote null.

      While executed directly into ant prints :
      [echo] alone in quote :
      [echo] OK
      [echo] not alone in text OK.
      [echo] not alone in quote OK.

      You can find in attachment the pom.xml and the ant.xml I used.

      1. ant.xml
        0.3 kB
        Gilles Scokart
      2. MANTRUN-36.patch
        8 kB
        Carlos Sanchez
      3. MANTRUN-36.patch
        9 kB
        Gilles Scokart
      4. pom.xml
        1 kB
        Gilles Scokart

        Issue Links

          Activity

          Hide
          Gilles Scokart added a comment -

          In have found in the reason in the code.

          When a property $

          {...} is placed into an XML text, the value is not processed by the PluginParameterExpressionEvaluator.
          The text is thus given as is to ant, that forward it to the AntPropertyHelper provided by the antrun mojo. It works as expected.

          When a property ${...}

          is placed alone in an attribute, the PluginParameterExpressionEvaluator evaluate it to null, the AntTargetConverter of
          the antrun plugin detect this null, and forward the original ${} to ant. It works as expected.

          When a property $

          {...}

          is placed with some text into an attribute (for example "a text $

          {x}

          "), the PluginParameterExpressionEvaluator evaluate it to a string
          containing "a text null", the AntTargetConverter of the antrun plugin forward this text to ant that doesn't detect a property. It is the bu I have found.

          The solution is to not use the PluginParameterExpressionEvaluator before, but only after ant property processing (into the AntPropertyHelper).

          Show
          Gilles Scokart added a comment - In have found in the reason in the code. When a property $ {...} is placed into an XML text, the value is not processed by the PluginParameterExpressionEvaluator. The text is thus given as is to ant, that forward it to the AntPropertyHelper provided by the antrun mojo. It works as expected. When a property ${...} is placed alone in an attribute, the PluginParameterExpressionEvaluator evaluate it to null, the AntTargetConverter of the antrun plugin detect this null, and forward the original ${} to ant. It works as expected. When a property $ {...} is placed with some text into an attribute (for example "a text $ {x} "), the PluginParameterExpressionEvaluator evaluate it to a string containing "a text null", the AntTargetConverter of the antrun plugin forward this text to ant that doesn't detect a property. It is the bu I have found. The solution is to not use the PluginParameterExpressionEvaluator before, but only after ant property processing (into the AntPropertyHelper).
          Hide
          Gilles Scokart added a comment -

          The attached patch should fix the bug.

          I'm not really happy with the solution used to pass the ExpressionEvaluator to the mojo, but I didn't find better. Indeed, as far as I have seen, the ExpressionEvaluator can neither be accessed as a component, neither as a maven property.

          Show
          Gilles Scokart added a comment - The attached patch should fix the bug. I'm not really happy with the solution used to pass the ExpressionEvaluator to the mojo, but I didn't find better. Indeed, as far as I have seen, the ExpressionEvaluator can neither be accessed as a component, neither as a maven property.
          Hide
          Carlos Sanchez added a comment -

          Imprved patch against current trunk

          Show
          Carlos Sanchez added a comment - Imprved patch against current trunk
          Hide
          Carlos Sanchez added a comment -

          test4 in plugin sources covers this issue

          Show
          Carlos Sanchez added a comment - test4 in plugin sources covers this issue
          Hide
          Carlos Sanchez added a comment -

          Applied patch but keeping backwards compatibility. It could be a better implementation, but this works for all it tests.

          Show
          Carlos Sanchez added a comment - Applied patch but keeping backwards compatibility. It could be a better implementation, but this works for all it tests.

            People

            • Assignee:
              Carlos Sanchez
              Reporter:
              Gilles Scokart
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: