Johann Goulley Johann Goulley - 2 months ago 10
Java Question

Maven archetype filename pattern with underscore

I'm creating a Maven archetype. I want to generate files like

project_todo_messages.properties
with
todo
replaced by a filtered property.

I created a file
project___todo___messages.properties
and a filtered property
todo
in
archetype-metadata.xml
and
archetype.properties
.
Files without underscore are renamed, but files with underscore around the filtered property are not. Any ideas?

I use maven-archetype-plugin 2.3 and org.apache.maven.archetype:archetype-packaging 2.3.

Other question : is it possible to lowercase a filtered value in a filename like it is possible in a file content with
${todo.toLowerCase()}
?

Answer

You can accomplish both by adding required properties with default values set to the filter you want.

For the first case:

<requiredProperty key="messagePropertiesFileName">
    <defaultValue>project_${todo}_messages</defaultValue>
</requiredProperty>

Name the file __messagePropertiesFileName__.properties.

For the second case, add yet another property:

<requiredProperty key="todoLowerCase">
    <defaultValue>${todo.toLowerCase()}</defaultValue>
</requiredProperty>

Use __todoLowerCase__ in folder/file names.