mvn-archetype
Generate new Maven projects from templates
TLDR
Generate a new project interactively
Generate a project non-interactively with specific archetype and project parameters
SYNOPSIS
mvn archetype:generate [-DarchetypeGroupId=<group>] [-DarchetypeArtifactId=<artifact>] [-DarchetypeVersion=<version>] [-DarchetypeCatalog=<catalog>] [-DgroupId=<group>] [-DartifactId=<artifact>] [-Dversion=<version>] [-DinteractiveMode=false] [-DbatchMode=true]
PARAMETERS
-DarchetypeGroupId
Specifies the group ID of the archetype to use. E.g., org.apache.maven.archetypes.
-DarchetypeArtifactId
Specifies the artifact ID of the archetype to use. E.g., maven-archetype-quickstart.
-DarchetypeVersion
Specifies the version of the archetype to use.
-DarchetypeCatalog
Specifies the catalog from which to retrieve the archetype. Common values include local, remote, internal, a URL, or a file path.
-DgroupId
Specifies the group ID for the new project being generated.
-DartifactId
Specifies the artifact ID for the new project being generated. This will also be the name of the project directory.
-Dversion
Specifies the version for the new project being generated. Defaults to 1.0-SNAPSHOT.
-DinteractiveMode
If true (default), Maven will prompt the user for input. If false, it will attempt to use defaults or other provided parameters without interaction.
-DbatchMode
When true, it avoids user prompts, effectively equivalent to -DinteractiveMode=false. Useful for scripting.
DESCRIPTION
The mvn archetype:generate command (often conceptually referred to as "mvn-archetype") is a core feature of Apache Maven for quickly bootstrapping new projects. It utilizes Archetypes, which are project templating tools in Maven. An archetype is essentially a project template that defines a basic project structure, including directories, pom.xml files, and sometimes sample source code. When archetype:generate is executed, Maven prompts the user (or uses provided parameters) to select an archetype from a catalog (local or remote) and then generates a new project based on that template.
This significantly speeds up initial project setup, ensuring consistency across different projects by providing a standard starting point for various project types like web applications, Maven plugins, or simple JAR libraries. It's crucial for developer productivity and maintaining project standardization within an organization.
CAVEATS
This is not a standalone Linux command. It is a goal (generate) of the archetype plugin executed via the mvn (Maven) command. Therefore, Apache Maven must be installed and configured on your system for this command to work. Without providing specific archetype coordinates in non-interactive mode, the command will require user interaction or fail.
WHAT IS A MAVEN ARCHETYPE?
An Archetype is a Maven project templating toolkit. It provides a consistent and reproducible way to generate new Maven projects from a predefined template. It encompasses the project's directory structure, a basic pom.xml file, and often boilerplate code, making it easy to start a new project without manually setting up the basic structure every time. Archetypes can be simple (like a basic Java application) or complex (like a multi-module enterprise application).
HISTORY
The concept of Archetypes was introduced early in Apache Maven's development as a solution for project bootstrapping and standardization. As Maven grew in popularity, the Archetype plugin became a fundamental tool for quickly creating new projects, leveraging community-contributed and organization-specific templates. Its usage has remained consistent, facilitating rapid project initiation and maintaining project structure consistency.
SEE ALSO
mvn clean, mvn compile, mvn package, mvn install


