Site icon TestingDocs.com

What is Maven?

Introduction

Apache Maven is a build automation tool. It is popularly used for build automation, dependency management, project life-cycle, continuous integration. One of the best features of Maven compared to the Ant tool, is that it will discover the dependency artifacts automatically.

Apache Maven is a tool for building software. It is configured with a POM (Project Object Model ) file. It runs in JVM and uses a distributed repository model. ( plugins and dependencies are kept in remote repositories ).

Installing Apache Maven

The only prerequisite for installing the tool is Java JDK. Installing maven is very easy, download and extract the tool into a folder and set the environment variable.

Detailed information on how to set up Maven is at:

https://www.testingdocs.com/installing-apache-maven-3-x-on-windows-10/

Environment variables

Configuration of environment variables

 

Project Object Model

The important file in the Maven project is pom.xml ( Project object Model ). Every project contains this file. POM is an XML file that contains information about project and configuration details used by Maven to build the project.

● The XML file pom.xml contains details about the project, dependencies
● POM may be hierarchical i.e it can have a parent POM and child POMs for a given project.
● Defines project identity, dependencies, plugins, repositories, parent POM, modules, properties, and many more.

 

Creating a simple maven project via command line or through Eclipse/IntelliJ IDEA IDE.

I have created a sample project through the following command to show in the post. Generally, Choose the IDE to create a quick maven project.

/> mvn archetype:generate -DgroupId=com.testingdocs.sample  -DartifactId=SampleProject

Sample POM


<project xmlns=”http://maven.apache.org/POM/4.0.0” 
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” 
 xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd”> 
 <modelVersion>4.0.0</modelVersion> 
 <groupId>com.testingdocs.sample</groupId> 
 <artifactId>Sample</artifactId>  
<version>1.0-SNAPSHOT</version> 
<packaging>jar</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

 

Maven Tutorials on this website can be found at:
https://www.testingdocs.com/apache-maven-tutorial/

 

Exit mobile version