πMaven Archetype
Describe about Maven Archetype
Maven Archetype is a Maven project templating toolkit that we can use to create our own custom template of the project (Think as a Image) , Then this image will be used to generate the project.
Advantage
Reduce time when we need to initialize new project
Have a standard project structure when we work with multiple team.
Component
Archetype Descriptor = Configure
selected file
that we want to use for generate in archetype and define which folder istest folder
orcode folder
. The location is insrc/main/resources/META-INF/maven
that consist ofarchetype.xml
orarchetype-metad.xml
Example:
Prototype file = Store the code and configuration. The location is in
src/main/resources/archetype-resources
Pom for generate project = Pom for generated project from archetype. The location is in
src/main/resources/archetype-resources
Pom for archetype = It is root level of archetype project or target folder ( If archetype is created from existing project )
How to create new project from archetype ?
use this command to generate the project
There are 2 way to create own archetype
Create new archetype project. ( can use maven archetype plugin to generate sample code)
Create archetype from existing project
How to create archetype from existing project ?
Run command
mvn archetype:create-from-project
(You can add -X to debug If error occured to debug)
If you found some issue maybe you need to create the settings.xml
in .m2
ref: https://stackoverflow.com/questions/59603307/calling-mvn-archetypecreate-from-project-on-a-simple-archetypewebapp-project-i
Verify correctness of code in
target/generated-sources/archetype/src/main/resources/archetype-resources
Navigate to folder
target/generated-sources/archetype
and run commandmvn clean install
Double check in
.m2/repository
whether the archetype is created or not.
For more information you can learn in this repository: https://github.com/brightkut/zeldra
Last updated