Use __groupId__ in archetype

2019-08-24 18:18发布

问题:

I'm trying to create a multi module archetype like the following:

__groupId__.plugin
__groupId__.feature

I want to set the names of the modules by groupId. So I use __groupId__ In order to set the module names. The problem is that these template doesn't get recognized. When I use __rootArtifactId__ my code works. Am I using the wrong template name?

I have the following structure:

archetype
 |--src
    |--main
        |--resources
            |--sonatype-resources
            |   |--__groupId__.plugin
            |   |--__groupId__.feature
            |   |--pom.xml
            |---META-INF
                |---maven
                    |---archetype-metadata.xml

The module description in archetype-metadata.xml looks like this:

<module id="${groupId}.plugin" dir="__groupId__.parent" name="${groupId}.plugin">
  <fileSets>
    <fileSet filtered="true" encoding="UTF-8">
      <directory></directory>
      <includes>
        <include>.project</include>
        <include>build.properties</include>
      </includes>
    </fileSet>
  </fileSets>
</module>
<module id="${groupId}.parent" dir="__groupId__.feature" name="${groupId}.feature">
  <fileSets>
    <fileSet filtered="true" encoding="UTF-8">
      <directory></directory>
      <includes>
        <include>.project</include>
        <include>build.properties</include>
      </includes>
    </fileSet>
  </fileSets>
</module>

回答1:

You can think of using the "packaged" property of the fileSet. By using it you can alter the "package" property default value and adding the files directly in the customized folder.