☀️
Dev7Days
  • 😄Welcome
  • Local Setup
    • ⚙️Setup Terminal
    • ⚙️Setup IDE
    • ⚙️Setup Neovim
  • Rust
    • 🦀Cargo
  • Java
    • 🍃Spring Boot
      • Spring Boot Annotaion
      • Spring Boot Learning
    • 🍃JDK vs JRE vs JVM
    • 🍃What is JDBC ?
    • 🍃What is Data Source in Java ?
    • 🍃Check vs Unchecked Exception
    • 🍃What is Servlet in Java ?
    • 🍃Filter vs Interceptor
    • 🍃Mockito
    • 🍃Maven CLI
    • 🍃Maven Archetype
  • Go
    • 🔹Go Routine and Channel
    • 🔹Go CLI
  • Ruby and Rails
    • ♦️Ruby Syntax
    • ♦️Rails Framework
    • ♦️Rails Structure
  • Fundamental
    • 📚Git Command
    • 📚Interpreter vs Compiler
    • 📚DTO vs DAO
    • 📚Http Status
    • 📚What is Batch Process ?
    • 📚Https
    • 📚Local Storage vs Session Storage vs Cookies
    • 📚Authentication & Authorization
    • 📚Database Index
    • 📚What is GRPC ?
    • 📚What is Microservice ?
  • Database
    • 🗃️What is Transaction ?
    • 🗃️ACID
  • Postgres
    • 🐘SELECT
    • 🐘Column Alias
    • 🐘Order By
    • 🐘SELECT DISTINCT
  • Elastic Search
    • 🔍What is Elastic Search ?
    • 🔍Node and Cluster
  • Kubernetes
    • ☸️What is Kubernetes ?
    • ☸️Kubernetes Architecture
      • Node
      • ETCD
      • Kube API Server
      • Controller Manager
      • Kube Scheduler
      • Kubelet
      • Kube Proxy
  • ☸️Pod
  • ☸️ReplicaSet
  • ☸️Deployment
  • ☸️Service
  • ☸️Config Map
  • ☸️Namespaces
  • ☸️Kube Apply Command
  • ☸️Scheduling
    • Manual Scheduling
    • Labels and Selectors
    • Taints and Tolerations
    • Node Selector
    • Node Affinity
    • Resource Requirements and Limits
    • DaemonSets
    • Static Pods
    • MultipleSchedulers
  • ☸️Monitoring
  • AWS
    • 🔸How can users access AWS ?
    • 🔸IAM
    • 🔸EC2
      • User Data
      • Instance Types
      • Security Group
      • Purchasing Options
      • Placement Groups
      • Elastic Network Interface (ENI)
      • EC2 Hibernate
      • EC2 Storage
    • 🔸ELB & ASG
      • Health Checks
      • Target Group
      • ELB Types
      • Sticky Sessions
      • Cross Zone Load Balancing
      • Load Balancer - SSL and SNI
      • Deregistration Delay
      • ASG
    • 🔸RDS & Aurora DB
      • RDS
        • Storage Auto Scaling
        • Read Replica
        • Multi AZ
        • RDS Custom
        • Backup
        • RDS Proxy
      • AWS Aurora
        • Read Replica
        • Endpoint and Auto Scaling
        • Aurora Serverless
        • Global Database
        • Machine Learning
        • Backup
        • Database Cloning
      • RDS & Aurora Restore options
      • RDS & Aurora Security
    • 🔸Elastic Cache
    • 🔸Route 53
      • Records
      • Hosted Zones
      • Health Check
      • Routing Policies
  • Backend Security
    • 🎩SQL Injection
    • 🎩Cross site script (XSS)
    • 🎩Cross site request forgery (CSRF)
    • 🎩Man in the Middle (MITM)
    • 🎩Insecure Direct Object Reference (IDOR)
    • 🎩Distributed denial of service (DDOS)
  • Medium
    • 👨‍💻Gamer to Coder
    • 🐳Docker
      • Docker #1
      • Docker #2
    • 💊DI and IOC
    • ☸️Kubernetes
  • Book
    • 📚System Design Interview - An Insider's Guide (Volume 1
Powered by GitBook
On this page
  • Advantage
  • Component
  • How to create new project from archetype ?
  • How to create archetype from existing project ?
  1. Java

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

  1. Reduce time when we need to initialize new project

  2. Have a standard project structure when we work with multiple team.

Component

  1. Archetype Descriptor = Configure selected file that we want to use for generate in archetype and define which folder is test folder or code folder. The location is in src/main/resources/META-INF/maven that consist of archetype.xml or archetype-metad.xml

Example:

// Example
<fileSets>
    <fileSet filtered="true" packaged="true" encoding="UTF-8">
      <directory>src/main/java</directory>
      <includes>
        <include>**/*.java</include>
      </includes>
    </fileSet>
    <fileSet filtered="true" encoding="UTF-8">
      <directory>src/main/resources</directory>
      <includes>
        <include>**/*.properties</include>
      </includes>
    </fileSet>
    <fileSet filtered="true" packaged="true" encoding="UTF-8">
      <directory>src/test/java</directory>
      <includes>
        <include>**/*.java</include>
      </includes>
    </fileSet>
<fileSets>    
  1. Prototype file = Store the code and configuration. The location is in src/main/resources/archetype-resources

  2. Pom for generate project = Pom for generated project from archetype. The location is in src/main/resources/archetype-resources

  3. 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 ?

  1. use this command to generate the project

mvn archetype:generate \
    -DarchetypeGroupId=<archetype-group-id> \
    -DarchetypeArtifactId=<archetype-artifact-id> \
    -DarchetypeVersion=<archetype-version> \
    -DgroupId=<new-project-group-id> \
    -DartifactId=<new-project-artifact-id> \
    -Dversion=<new-project-version> 

There are 2 way to create own archetype

  1. Create new archetype project. ( can use maven archetype plugin to generate sample code)

  2. Create archetype from existing project

How to create archetype from existing project ?

  1. Run command mvn archetype:create-from-project (You can add -X to debug If error occured to debug)

  1. Verify correctness of code in target/generated-sources/archetype/src/main/resources/archetype-resources

  2. Navigate to folder target/generated-sources/archetype and run command mvn clean install

  3. Double check in .m2/repository whether the archetype is created or not.

PreviousMaven CLINextGo Routine and Channel

Last updated 11 months ago

If you found some issue maybe you need to create the settings.xml in .m2 ref:

For more information you can learn in this repository:

🍃
https://stackoverflow.com/questions/59603307/calling-mvn-archetypecreate-from-project-on-a-simple-archetypewebapp-project-i
https://github.com/brightkut/zeldra