Create a Maven archetype from an existing project on Eclipse

First, a mvn archetype:create-from-project and a mvn install on the created archetype in target/generated-sources/archetype directory.

A directory, named ${groupId}/${artifactId}-archetype, containing a jar and pom.xml is generated into the repository.

A mvn archetype:crawl -Drepository=/path/to/.m2 is then used to generate the archetypes catalog. The archetype-catalog.xml file is by default generated in .m2/repository (this can be changed while using the parameter -Ddirectory=/path/for/xml)

Finally, in Eclipse, go to Window > Prefences > Maven > Archetypes > Add local catalog, enter the name and directory of this catalog.

When you create a new Maven project on Eclipse, you can select your ${groupId}/${artifactId}-archetype in your catalog freshly named.

More on :

http://maven.apache.org/plugins/maven-archetype-plugin/advanced-usage.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s