Search This Blog

Wednesday, December 7, 2011

Create a maven archetype from an existing project

In your project's root directory, run the following command:

mvn archetype:create-from-project

The generated archetype is in directory target/generated-sources/archetype

Move above folder to different folder, say: /path/to/myarchetypeOpen pom to change <name> tag, and groupId and artifactId. To add additional required field, open archetype-metadata.xml file (src/main/resources/META-INF/maven) and add one required property, using <requiredProperties> tag.

To install archetype into local catalog:
mvn clean install

To generate a new project from the installed archetype:

mvn archetype:generate -DarchetypeCatalog=local