Tarin Gamberini

A software engineer and a passionate java programmer

How to create a Maven archetype in NetBeans

Creating a Maven archetype from an existing project with NetBeans is very easy.

Table of Contents

Creating a Maven archetype

  1. Take your existing project to use as a template. This is the project as it will be created.
  2. In NetBeans right click on your project template name, choose Custom > Goals..., write in the Goals textfield the archetype:create-from-project goal and finally click OK. Otherwise at your project template pom directory you may also run:
$ mvn archetype:create-from-project
  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>.
  2. 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.
  3. Once it’s all ok you have to install the archetype in your local Maven repository, so run mvn clean install.
  4. 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.
  5. 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 run mvn 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.