Create New Maven Project


Apache Maven is a software project management and comprehension tool. It manages the project build using the project object model (POM) XML. The pom.xml file is the Project Object Model (POM), a declarative description of a project. Other than the project’s POM, there is also a super POM defined within Maven. When a maven goal is run, it always executes against an effective POM, a combination of settings from this project’s pom.xml, all parent POMs and the Super POM.

Generate a Maven Project

In order to create a maven project, we need to execute the below command:

mvn archetype:generate -DgroupId=com.javarticles.maven 
-DartifactId=mavensamples -DpackageName=com.javarticles.maven

archetype:generate is the plugin goal where archetype is the identifier of a plugin and generate is the identifier of a goal. The prefix archetype is the plugin that contains the goal. A Maven plugin is a collection of one or more goals and a goal is similar to ant’s concept of task.

The generate goal creates a simple project based upon an archetype. There are many examples of in-built plugins, for example, a Jar plugin that contains goals for creating JAR files.
Goals are configured via configuration properties that can be used to customize behavior. For our generate goal, we have passed key configuration elements groupId, artifactId and packageName. These are called Maven coordinates, which uniquely identify a project.
You can specify the archetype kind as a configuration parameter based on the type of project. By default it is quick start up.
archetypeArtifactId is the configuration parameter and its default value is set to maven-archetype-quick


[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources
@ standalone-pom >>>
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate-sources
@ standalone-pom <<<
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom --
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.
[INFO] Using property: groupId = com.javarticles.maven
[INFO] Using property: artifactId = mavensamples
Define value for property 'version':  1.0-SNAPSHOT: :
[INFO] Using property: package = com.javarticles.maven
Confirm properties configuration:
groupId: com.javarticles.maven
artifactId: mavensamples
version: 1.0-SNAPSHOT
package: com.javarticles.maven
 Y: :
[INFO] -------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype:
[INFO] -------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: C:\
[INFO] Parameter: package, Value: com.javarticles.maven
[INFO] Parameter: groupId, Value: com.javarticles.maven
[INFO] Parameter: artifactId, Value: mavensamples
[INFO] Parameter: packageName, Value: com.javarticles.maven
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\mavensamples
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44:49 min
[INFO] Finished at: 2015-11-18T10:45:06+05:30
[INFO] Final Memory: 16M/351M
[INFO] ------------------------------------------------------------------------

Maven Directory Structure

Once the command is executed, you will see a new directory with the same name given as the artifactId.

Maven Directory

Maven Directory


The quick start archetype generates a minimal project shell that contains a POM and a single class.


<project xmlns="" xmlns:xsi=""






package com.javarticles.maven;

 * Hello world!
public class App 
    public static void main( String[] args )
        System.out.println( "Hello World!" );

Comments are closed.