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

Property not available in config when defaultValue in descriptor contains token

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Component/s: Generator
    • Labels:
      None
    • Environment:
      any
    • Flags:
      Patch

      Description

      There is a bug with property resolving when calling archetype:generate mojo. Default property value provided in archetype descriptor hides the value passed as parameter to mojo.

      archetype-metadata.xml:

      <requiredProperty key="foo">
        <defaultValue>${some.name}</defaultValue>
      </requiredProperty>

      running:

      mvn archetype:generate ... -Dfoo=bar
      ...
      Define value for property 'foo':  ${some.name}: :

      Generation stops and asks for value of property foo although it was passed as parameter.

      I have attached example archetype and patch that solves this issue.
      Please review and focus on suspicious line (112 before patching, 116 after patching).
      Basically the default value from metadata should be ignored, when value is explicitly set.

      Handling nested tokens is a different story...

      1. test_and_patch.tgz
        1 kB
        Petr Janata
      2. archetype-349.patch
        4 kB
        Jesse McConnell

        Activity

        Hide
        hboutemy Hervé Boutemy added a comment -

        IT improved to a real automated test using archetype:integration-test with a reference generated project in r1163284

        Show
        hboutemy Hervé Boutemy added a comment - IT improved to a real automated test using archetype:integration-test with a reference generated project in r1163284
        Hide
        brettporter Brett Porter added a comment -

        Patch applied, thanks both!

        Show
        brettporter Brett Porter added a comment - Patch applied, thanks both!
        Hide
        jmcconnell Jesse McConnell added a comment -

        reformatted patch, applies from the top of the archetype project

        Show
        jmcconnell Jesse McConnell added a comment - reformatted patch, applies from the top of the archetype project

          People

          • Assignee:
            brettporter Brett Porter
            Reporter:
            petrjanata Petr Janata
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development