Creating Maven Project

This lesson gives a brief introduction to Maven. It is more like a guide to set a Maven project on our system, depending on its requirements.

What is Maven? #

Apache Maven is a software project management and comprehension tool that can manage a project’s build, reporting, and documentation from a central piece of information, making it a complete build lifecycle framework.

System requirements #

Maven 3.3+ requires JDK 1.7 or above to execute. They still allow you to build against 1.3 and other JDK versions.

Installation #

The current latest Maven can be downloaded from apache-maven-3.6.3.

To find the latest version, please follow the link.

The downloaded binary needs to be added to classpath after extraction.

Windows #

export PATH=%PATH%;<path\apache-maven-3.6.3\bin>;

Linux / Mac #

export PATH=$PATH:<path/apache-maven-3.6.3/bin>

Alternatively, we can install using brew:

brew install maven

For installing brew, please follow the link.

Creating Maven project from the command line #

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
  • archetypeArtifactId: a starter template to use for creating the basic project structure.
  • groupId, artifactId, and version: this combination enables you to identify an artifact uniquely. groupId is mostly the company’s domain reversed. For example, groupId of example.com is created as com.example. Version can be in format as <major.version>.<minor.version>.<patch.number>-<RELEASE/SNAPSHOT>. For example, 1.0.0-SNAPSHOT or 1.0.0-RELEASE. Please follow the link for more information.

By running the above command, a basic project structure will be created.

Get hands-on with 1400+ tech skills courses.