Site icon TestingDocs.com

Maven Archetype plugin command line

Introduction

Maven archetype plugin allows us to create projects based on predefined structure and template. Let’s see how to work with the Maven archetype plugin command line. Add the bin folder path of your maven installation to the PATH environment variable, so that you can run anywhere in the console the mvn command.

Create a Project Command line

To get started with creating a maven project with a template in interactive mode, issue the following command. However, you can suppress the interactive mode and supply the necessary project details with -D command-line options.

Archetype

\> mvn archetype:generate

 

Choose the archetype with a number. Maven would display all available archetypes for you with a number and short description.

Enter the number to start building the particular project template. The default number will be displayed. in the command line as shown below:

i.e 1027 maven-archetype-quickstart

1027: remote -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.)

Choose the version of the archetype. The number of versions displayed would vary from one archetype to another. The default is the latest version if you choose to skip.

Project details

Maven prompts you to enter the project details like groupId, artifactId , version, package , other necessary details etc.

Once you confirm the project details, Maven will start building the project. Maven would create all the necessary project structure, source, and other files automatically.

You would see a ‘Build success’ message displayed at the end of the process.

 

You are done with creating the project with the chosen archetype with Maven.

Exit mobile version