I am trying to create a maven archetype in which I am trying to autogenerate the code in a java class. I have came across jcodemodel to generate java class. Anyone kindly guide me hoe to do it and where do i need to use jcodemodel in archetype inorder to generate a class file in specific folder with a given name from user?
The archetype gets the input such as servicename, artifactid from user while generating code.
Maven archetypes can use velocity templates to create code, one simple example beeing to create to correct package definitions. The JBoss Wiki contains a simple example of a template containing conditional logic.
If you already have a generator using codemodel, the generate goal of the archetype plugin contains a
goalsparameter the execute additional plugins after creation. You could let the archetype create only the directory structure, wrap your generator into a maven plugin and then execute on the newly created project.