Maven
  1. Maven
  2. MNG-4464

Improve handling of relative paths with backslashes

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.1, 3.0-alpha-4
    • Fix Version/s: 3.0-alpha-7
    • Component/s: POM
    • Labels:
      None
    • Environment:
      Unix, Mac
    • Complexity:
      Intermediate
    • Number of attachments :
      0

      Description

      Consider this snippet:

      <parent>
        <relativePath>..\pom.xml</relativePath>
      </parent>
      

      Note in particular the backslash used in the path. While this path will be properly resolved on a Windows box, it will fail to resolve the local parent on a Unix/Mac box (as the backslash is not a separator but escape character here). This applies to other paths in the POM as well.

      For platform-independent behavior, we should either encourage the user to use forward slashes (by means of validation warnings/errors) or have Maven convert the paths internally.

        Issue Links

          Activity

          Hide
          Anders Kr. Andersen added a comment -

          In my eyes writing <relativePath>..\pom.xml</relativePath> means <<dot>> <<dot>> <<escapeP>> <<letter o>> <<letter m>> etc.
          And it makes no sense.
          a correct way must be to write <relativePath>../pom.xml</relativePath>

          I have written <relativePath>../pom.xml</relativePath> several places, and it seems to work.

          So yes backslash is an error. And should procduce a warning.
          The question is just how do we know that escape is used wrong?
          A sentence like <relativePath>\<SYSTEM\$HOME\>pom.xml</relativePath> could make sense on Open VMS.

          My conclusion is that this is just something that developers should know.

          A simulary situation is to write <relativePath>$

          {myParameter}/pom.xml</relativePath> and not having set a value to property myParameter. In this case maven tells that it cannot find file ${myParameter}

          /pom.xml.

          Maybe maven's pom checkker tool could be told to check for these things?

          Show
          Anders Kr. Andersen added a comment - In my eyes writing <relativePath>..\pom.xml</relativePath> means <<dot>> <<dot>> <<escapeP>> <<letter o>> <<letter m>> etc. And it makes no sense. a correct way must be to write <relativePath>../pom.xml</relativePath> I have written <relativePath>../pom.xml</relativePath> several places, and it seems to work. So yes backslash is an error. And should procduce a warning. The question is just how do we know that escape is used wrong? A sentence like <relativePath>\<SYSTEM\$HOME\>pom.xml</relativePath> could make sense on Open VMS. My conclusion is that this is just something that developers should know. A simulary situation is to write <relativePath>$ {myParameter}/pom.xml</relativePath> and not having set a value to property myParameter. In this case maven tells that it cannot find file ${myParameter} /pom.xml. Maybe maven's pom checkker tool could be told to check for these things?
          Benjamin Bentmann made changes -
          Field Original Value New Value
          Link This issue depends upon PLX-450 [ PLX-450 ]
          Hide
          Paul Benedict added a comment -

          I opt for a warning to be produced in 3.0 and trigger an error in 3.1. To "encourage the user", warnings are the best means.

          Show
          Paul Benedict added a comment - I opt for a warning to be produced in 3.0 and trigger an error in 3.1. To "encourage the user", warnings are the best means.
          Hide
          Benjamin Bentmann added a comment -

          Revised separator handling in r904931.

          I opted to accept both forward and backslash as file separators. For one, this matches Ant's behavior. And for second because issueing a warning from all relevant code spots isn't feasible.

          Show
          Benjamin Bentmann added a comment - Revised separator handling in r904931 . I opted to accept both forward and backslash as file separators. For one, this matches Ant's behavior. And for second because issueing a warning from all relevant code spots isn't feasible.
          Benjamin Bentmann made changes -
          Resolution Fixed [ 1 ]
          Fix Version/s 3.0-alpha-7 [ 16087 ]
          Assignee Benjamin Bentmann [ bentmann ]
          Status Open [ 1 ] Closed [ 6 ]
          Benjamin Bentmann made changes -
          Link This issue relates to MNG-5035 [ MNG-5035 ]

            People

            • Assignee:
              Benjamin Bentmann
              Reporter:
              Benjamin Bentmann
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: