Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camel case file name from artifactId for Maven archetype?

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

like image 424
Arun Gupta Avatar asked Jan 04 '16 01:01

Arun Gupta


1 Answers

I fixed it as follows:

    <requiredProperty key="classPrefix" >
        <defaultValue>
            ${package.getClass().forName("org.apache.velocity.util.StringUtils").removeAndHump("$artifactId", "-")}
        </defaultValue>
    </requiredProperty>
like image 163
ehansbo Avatar answered Oct 02 '22 05:10

ehansbo