views:

33

answers:

1

Hi chaps, I've created a Maven archetype for a custom project setup, which is working wonderfully, but I was wondering if it's possible to pass extra parameters so that I can do some more interesting templating. I tried something like

mvn archetype:generate -DarchetypeCatalog=local -DdbHost=localhost

and put

...
<option name="db.host.config.option" value="${dbHost}" />
...

in my template, but that doesn't seem to work. Is there a way to do this with an archetype?

A: 

you just have to mention dbHost as requiredProperty in META-INF/maven/archetype-metadata.xml. ...

bitover
Thanks, could you expand on that a bit? I'm not sure I'm familiar enough with the syntax.
Ceilingfish
sure. In your archetype project, you have to create a folder project/META-INF/maven. In that folder you have to create a file called archetype-metadata.xml. In that file you should add requiredProperty tags for each of the configuration argument you would like to have. You can find more details here http://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-metadata.html
bitover