8

For a Maven archetype, how to camel case a generated file name using ${artifactId} in archetype-metadata.xml? For example, sample-my should give SampleMy.java.

I supposed this is needed to be a velocity template but this require a macro to be specified in archetype-metadata.xml. The macro could be created in pluginApp.java as shown at:

https://github.com/arun-gupta/spigot-archetype/blob/master/src/main/resources/archetype-resources/src/main/java/pluginApp.java#L4-L7

How can it be done archetype-metadata.xml?

Exact fragment in question is at:

https://github.com/arun-gupta/spigot-archetype/blob/master/src/main/resources/META-INF/maven/archetype-metadata.xml#L14

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
Arun Gupta
  • 3,965
  • 5
  • 31
  • 39
  • I also searched for a solution an find it here: http://stackoverflow.com/questions/18773114/creating-maven-archetype-setting-file-name – Entwicklerfokus Nov 08 '16 at 20:15
  • Possible duplicate of [Creating Maven ArcheType . Setting file name](https://stackoverflow.com/questions/18773114/creating-maven-archetype-setting-file-name) – Carlo Zanocco Aug 29 '18 at 18:26

1 Answers1

5

I fixed it as follows:

    <requiredProperty key="classPrefix" >
        <defaultValue>
            ${package.getClass().forName("org.apache.velocity.util.StringUtils").removeAndHump("$artifactId", "-")}
        </defaultValue>
    </requiredProperty>
ehansbo
  • 51
  • 1
  • 2