Howto create dynamic named folders with Maven2 Archetype?

Posted by chrsk on Stack Overflow See other posts from Stack Overflow or by chrsk
Published on 2010-05-10T12:41:09Z Indexed on 2010/05/10 17:54 UTC
Read the original article Hit count: 255

Filed under:
|

Hey, i try to build a structure like this

+---src
    +---main
        +---webapp
            +---WEB-INF
                +---cfg
                ¦   +---log4j
                ¦   +---resources
                ¦       +---extensions
                ¦           +---${artifactIdKey}-business
                ¦           +---${artifactIdKey}-layout
                +---lib

I added a required property to my archetype-metadata.xml to have an short-name for the project, which is used among other things for generating unique folders.

<requiredProperties>
  <requiredProperty key="artifactIdKey" />
</requiredProperties>

The property artifactIdKey i use in a fileSet:

<fileSet>
  <directory>[..]/resources/extensions/${artifactIdKey}-business</directory>
</fileSet>

<fileSet>
  <directory>[..]/resources/extensions/${artifactIdKey}-layout</directory>
</fileSet>

The command to generate the archetype:

mvn archetype:generate -B \
       -DgroupId=com.stackoverflow \
       -DartifactId=stackoverflow-question -DarchetypeGroupId=com.stackoverflow \
       -DarchetypeArtifactId=stackoverflow-archetype -DarchetypeVersion=1.0 \
       -DartifactIdKey=soq

I assume to get the following folder structure, but i get the ${artifactIdKey} property as folder. Without beeing replaces.

..\
   +---soq-business
   +---soq-layout

..\
   +---${artifactIdKey}-business
   +---${artifactIdKey}-layout

How can i achieve this? And how can i place files below soq-business? Without knowing the folder name at this time?

© Stack Overflow or respective owner

Related posts about maven-2

Related posts about archetypes