java - Can I convert an artifactId to a classname prefix in my maven archetype? -
i'm creating maven archetype , in projects generated want class named after artifact id of generated project.
the artifact id formatted like: the-project-name , class should named theprojectnamemain.
i've tried in archetype-metadata.xml can't right.
<archetype-descriptor> <requiredproperties> <requiredproperty key="classnameprefix"> <defaultvalue>${wordutils.capitalize(artifactid.replaceall("-", " ")).replaceall(" ", "")}</defaultvalue> </requiredproperty> </requiredproperties> </archetype-descriptor> as can see tried use wordutils (from apache-commons) i'm guessing not available because i'm getting error. error merging velocity templates:.... . tried different combinations of .replaceall couldn't right format.
does know of way go a-hypenated-string camelcaseclassname in case?
there no access arbitrary java classes velocity, can call methods of existing objects. in context of maven archetype can use methods java.lang.string , velocity loop job done.
#macro( ccase $str ) #foreach( $word in $str.split('-') )$word.substring(0,1).touppercase()$word.substring(1)#end #end #set( $classnameprefix = "#ccase( $artifactid )" ) public class ${classnameprefix}application { // ... } if using fileset tag, add filtered="true" property make sure source files processed velocity.
see also:
Comments
Post a Comment