viernes, 11 de enero de 2013

Maven Archetype from Existing Project

Hi there,

So this weeks I've been having to mess around with Maven, in particular with archetypes.
Being new at this particular aspect of the Maven world I started where almost anyone will the Maven documentation page.

Any way.......

Thing is, this helped me a lot to understand the structure of a Maven archetype project but it didn't get me to create an archetype in an easy way.
In the end I found this blog.

As it turns out, the easiest way to create a Maven archetype is using an existing maven project.
Which makes senses.
As with anything in life if you like to create a template for something it's easier to create that something an then extract the template.

So this is the case, and the way to achieve this is:

mvn archetype:create-from-project

This will create a maven archetype from a project and will leave this new archetype project in:

target/generated-sources/archetype/

Now that you have you're base archetype you can start to tune it, and when you're ready to go just do:

mvn install

This will install the archetype in your local m2 repo.

Finally for those of you who don't know how to use this archetype one it's in place, this is the way:

mvn archetype:generate -DarchetypeGroupId={group.id.defined.in.the.archetype} -DarchetypeArtifactId={artifact-id-defined-in-the-archetype}



And that's it, have fun


No hay comentarios:

Publicar un comentario