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

Access to the parent artifactId and groupId during module generation

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Auto Closed
    • 2.2
    • None
    • Archetypes
    • None
    • all

    Description

      Hello,

      In some use cases when generating modules in a multi-modules project, it would be good to have access to the current parent properties and more especially to the parent artifactId and parent groupId.

      For instance, if we consider the following project structure:

      • myProject [com.test.myProject-1.0]
      • webapps [com.test.myProject.webapps-1.0]
      • libs [com.test.myPorject.libs-1.0]

      When creating a new webapp using whatever archetype under the webapps folder, there's no way to tell the plugin to set the groupId of the new module to com.test.myProject.webapps.

      There are couple of workarounds:

      • don't set any groupId in the new module but then it will inherit the parent groupId which is com.test.myProject (we loose the webapps or libs which is not what we want)
      • use the variables ${project.parent.groupId} and ${project.parent.artifactId} to set the modules's groupId but this brings instability and might not be supported in future version of Maven.

      so the solution would be to be able to use parentGroupId and parentArtifactId properties when generating the module, having something like:
      ...
      <groupId>${parentGroupId}.${parentArtifactId}</groupId>
      ...

      in the archetype resources' pom.xml.

      and of course doesn't prompt for the groupId while generating the module (this can be done with default values in the archetype's metadata)

      Regards

      Attachments

        Activity

          People

            Unassigned Unassigned
            jkuhn Jeremy KUHN
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: