Creating a Maven archetype from an existing project with NetBeans is very easy.
Table of Contents
Creating a Maven archetype
- Take your existing project to use as a template. This is the project as it will be created.
- In NetBeans right click on your project template name, choose
Custom > Goals...
, write in theGoals
textfield thearchetype:create-from-project
goal and finally clickOK
. Otherwise at your project template pom directory you may also run:
1
|
|
- Now you can find the generated archetype in the
target/generated-sources/
directory. Such an archetype is a Maven project itself but with the packaging type:<packaging>maven-archetype</packaging>
. - Open the generated archetype (double click on the generated archetype name) and edit the pom accordingly your specific needs: don’t accept the pom automatically generated without having a look at it.
- Once it’s all ok you have to install the archetype in your local Maven repository,
so run
mvn clean install
. - Create an archetypes catalog in your Maven local repository by running
mvn archetype:crawl
. Make sure your IDE is aware of the newly created archetype forcing a re-indexing of your Maven local repository. - Finally test your archetype by creating a new project.
From the NetBeans IDE right click on the Project window and choose
New Project... > Maven > Project from Archetype
, then select your archetype from the ones listed; or at command line simply runmvn archetype:generate -DarchetypeCatalog=local
.
Post a comment
A comment is submitted by an ordinary e-mail. Your e-mail address will not be published or broadcast.
This blog is moderated, therefore some comments might not be published. Comments are usually approved by the moderator in one/three days.