Introduction to MAVEN

Kawee Lokuge
3 min readApr 29, 2018

--

Introduction

MAVEN is a tool for setting up the development environment and manage the project. It has no use after the project is finally created and deployed. It is written in Java and developed by Apache Software Foundation.

Why MAVEN?

When creating java projects we are using additional files such as jar files. To add these files to the project we have to go to the specific site that contain the file then download the file and set the class path to the file. So it takes lot of development time for the project configuration. Maven works by doing these tasks for you. Hence MAVEN is built on top of the concept Convention over Configuration.

How MAVEN Works?

Simply we add the project files we intend to use as dependencies. Then MAVEN will download the needed files and make these files available to the project.

Behind the Scene

There is a file called project configuration file (pom.xml) where we specify all the dependencies we need. Then MAVEN will read this configuration file and checks if the needed files are in the Maven local repository which resides in your local computer. If the files are not there then MAVEN will download the necessary files from the Maven central repository (Remote). Then MAVEN will copy these files to the local repository for reuse. Finally the intended files are added to the project.

Basic Concepts

Standard Directory Structure

MAVEN provides an initial standard directory structure for easier file management.

source: https://www.javaworld.com/article/2072203/build-ci-sdlc/an-introduction-to-maven-2.html

pom.xml — Main configuration file

src/main/java — Java Source code

src/main/resources — Properties / resource files

src/main/webapp — JSP files and other web related files(web config files, js, CSS)

src/test — Files needed for unit testing

target — Directory for holding complied java code

POM (Project Object Model) File

Main configuration file in the project that manages the dependencies needed. POM file consist of three main components.

1. Project Meta data.

2. Dependencies

3. Plug-ins

source: http://www.seleniumeasy.com/maven-tutorials/create-a-simple-maven-project-in-eclipse

Let’s go into more Detail….

Project Meta Data

<groupId>-Name of the company/group

<artifactId>- Name of the working project

<version>- Release version of the project. E.g.- 1.0, 1.8 if the Project is under development 1.0-SNAPSHOT is used.

Dependencies

Additional files needed for the project.

E.g.-Springboot files, Hibernate files

MAVEN Archetypes

Templating toolkit that contains files to start a project immediately.

Following are the most common archetypes used.

maven-archetype-quickstart - Generating a sample MAVEN application.

maven-archetype-webapp - Generating a sample MAVEN Webapp project.

References -

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Responses (1)

Write a response