Search code examples
mavenmaven-pluginmaven-assembly-plugin

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.


Solution

  • 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)