Thursday, 15 August 2013

Manipulating __artifactId__ during file generation by maven archetype -



Manipulating __artifactId__ during file generation by maven archetype -

building maven archetype files generated using _artifactid_. archetype.xml looks like:

<sources> <source>src/main/java/__artifactid__.java</source> <source>src/main/java/__artifactid__commandexecutor.java</source> <source>src/main/java/__artifactid__eventlistener.java</source> </sources>

generating project using archetype can lead java file names not follow naming convention such sample-plugin.java , sample-plugincommandexecutor.java.

how can create sure _artifactid_ converted appropriate java file name, such sampleplugin.java , sampleplugincommandexecutor.java.

i'm not archetype expert, in fact did 1 time faced similar problem.

i not able find way customize file or directory names in way, mean utilize 1 of archetype parameters , transform it.

so there 2 kinds of solution used

add new archetype parameter specify class name use standard name (like artifactclass.java) , create maven profile (enabled if file present) ant script changes name (just remember within files can utilize velocity customize it)

hope helps tonio

maven maven-3 maven-archetype

No comments:

Post a Comment