Uploaded image for project: 'Maven Archetype'
  1. Maven Archetype
  2. ARCHETYPE-492

Underscore in filenames problematic due to greedy regex

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 3.1.0
    • Component/s: Plugin
    • Labels:
      None
    • Environment:
      Windows 7, Sun JDK

      Description

      If you have a file in a project with an underscore adjacent to a substitution variable, the substitution will fail i.e.

      if artifactId is 'Test' and a target file is to be named something_test.txt the file in the template should be named something___artifactId.txt (3 underscores in the middle) but the result is an error stating that the property _artifactId cannot be found. This is because the term inside the regex is a greedy .* - a simple fix would be to change this to something like __[^_]*__ which would only match non-underscore characters.

      Fixing this issue would allow the use of underscores in filenames in all circumstances rather than the current situation where you may get lucky. The only down side to fixing this issue is that properties with leading or trailing underscores will not be valid - this seems a far more preferable situation.

      A patch for this issue was put on this bug back in 01//2009 but somehow got ignored - see Alexander Maslov patch and comments at the end of this issue: https://issues.apache.org/jira/browse/ARCHETYPE-191

      Apologies for the formatting - it appears double underscores are an issue

        Attachments

          Activity

            People

            • Assignee:
              gboue Guillaume Boué
              Reporter:
              oliver.dungey Oliver Dungey
            • Votes:
              5 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: