Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a maven Archetype from an existing archetype

Is it possible to create an application specific archetypes using an existing 'Generic' archetype?.

Generic Archetype - would contain the generic folders and config files etc. Extend the existing archetype to the child archetype.

Generic Archetype ---> Specific App Archetype (Keep app specific folders..)

Generic Archetype ---> Specific App Archetype 1

Every time when we create a project using application specific archetype should check for new updates in Generic archetype.

like image 839
eagerToLearn Avatar asked Mar 28 '16 16:03

eagerToLearn


People also ask

How do you know the which archetype an existing maven project is built on?

Archetype configuration You can see the packaging maven-archetype . You can customize build of your archetype here as with any other pom. However, there is another pom. xml file located under src\main\resources\archetype-resources which is the pom file of the generated project.

What is archetype while creating maven project?

In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The name fits as we are trying to provide a system that provides a consistent means of generating Maven projects.

How do I find my maven archetype?

The Maven archetype descriptor is the heart of the archetype project. It's an XML file named archetype-metadata. xml and located in the META-INF/maven directory of the jar. The requiredProperties tag is used for providing properties during project generation.

Which maven archetype should I use?

If you want a web application, use maven-archetype-webapp, or if you want a simple application use maven-archetype-quickstart.


1 Answers

For me, you have two main choices :

  1. You can create your own archetype from nothing. Here is the official guide. You have few steps to follow (create a pom.xml, an archetype.xml,...).

  2. You can create an archetype from an existing project folder. For example, first, you can create a project from a Maven archetype (like "maven-archetype-webapp") of a web application. Then, you make your changes (add or modify some configuration files, create a folder for a specific purpose, etc.). And finally, you can create you own archetype, from this project, executing this command line :

    mvn archetype:create-from-project

A mini guide to create an archetype from a existing project.

Reference doc to create an archetype from a existing project (mojo infos)

like image 81
jpmottin Avatar answered Sep 19 '22 14:09

jpmottin