professional-Deveops logo



Maven Introduction 

Maven is a software project management and comprehension tool from Apache. Maven is derived from the Yiddish language, meaning the accumulator of knowledge. With Maven, developers can automate a project’s build infrastructure with its repository of standard directory layout and a default build lifecycle. 

Maven helps deliver work as per industry standards with its simple and reusable features, it makes the developer's task easy to create reports, checks, build and test automation setup.

Evolution of Maven 

Maven project was conceptualized originally for the Jakarta Turbine project, where there were several projects with their own Ant build files differing slightly from each other, to which JARs (Java Archive) were checked into CVS. Hence, this gave birth to Maven, which was designed to support multiple project-builds at a time, publish project information, deploy projects, and facilitate sharing JAR files across projects to strengthen collaboration between teams. 

Objectives of Maven:

Maven allows a developer to understand the development efforts within a very short time. And therefore, Maven aims to achieve the following set of objectives for any given project:

  • Easy build process – Maven aims to provide a black box that takes an input and gives an output without the need for the developers to know what’s going on inside it. 
  • Uniform build system – Maven uses Project Object Model (POM) along with a few
  • Quality project information – developers can use Maven to retrieve information regarding changelogs, cross-referenced sources, mailing lists managed by projects, dependencies on a project, unit test reports including coverage, and so on. Maven plugins are available for third-party code analysis products that add reports to the standard information given by Maven. 
  • Better development practices – one of the main objectives of Maven is to ensure the implementation of some best practices to guide a project better in a certain direction. Some of the best practices that must be followed for any unit test are –
    1. Keep source code separate. 
    2. Naming conventions are important for a test case to locate and execute tests.

Maven Setup:

When we talk about setup, it refers to the process of installation and configuration of any software. Maven uses Convention, which implies that there is no need for a developer to engage themselves in the build process. Maven has a default project structure, which is created automatically when a project is started, the developer just needs to place files as per requirement and need not indulge in any configuration hassles. 

Maven typically requires the following System requirements:

  1. Java Development Kit 1.7 or above.
  2. Disk size should typically vary around 10 MB for Maven installation.
  3. No specific requirement for operating system or memory. 

A Maven project stores files under the following default locations –

  • Source code - ${basedir}/src/main/java
  • Resources - ${basedir}/src/main/resources
  • Tests - ${basedir}/src/test
  • Compiled byte code - ${basedir}/target
  • distributable JAR - ${basedir}/target/classes

Developers can define project life cycle goals and project dependencies with the help of a robust library of Maven plugins.

Features of Maven:

Maven offers a very simple architecture for developing software. We summarize the features of Maven as follows:

  • A simple project setup that follows best practices.
  • Consistency of workflow across all projects.
  • A robust repository of libraries.
  • Easy to write and integrate plugins in Java or scripting language.
  • Quick access to new features without much need for additional configuration.
  • Maven has the flexibility to support any number of projects into predefined output types such as JAR, metadata, WAR, and so on without much scripting required.
  • Provides superior dependency management which includes automatic updates, dependency closures.
  • Maven can generate documentation for a project in either web site or PDF format and adds standard reports about the state of project development.
  • Maven supports release management and distribution for a project by integrating source control systems such as Subversion or Git. These can be published to a distribution location which can be used by other projects.
  • Maven recommends using the central repository of JARs and other dependencies. It provides a mechanism that clients can use to download any JAR, to build a project from a central JAR repository like Perl’s CPAN (Comprehensive Perl Archive Network). 

Maven Plugins:

Some of the popular Maven plugins worth mentioning are as follows –

  • Clean – clean up after a build.
  • Compiler – used to compile Java sources.
  • Deploy – used to deploy build artifacts to a remote repository.
  • Failsafe – developers can use this plugin to run Junit integration tests in the isolated classloader. 
  • Install – the plugin is used to install built artifacts into a local repository.
  • Resources – this plugin is used to copy resources to the output directory to be included in the JAR.
  • Site – can be used to generate a site for the current project.
  • Surefire – used to run Junit unit tests in the isolated classloader.
  • Verifier – helps in verification of integration tests to test certain conditions.

Maven Community:

Maven has a large community of users who contribute towards improvements, reporting defects, communicating use cases, writing documentation, and aiding users who need help. The Maven community comes with a robust guide for Maven users emphasizing more on beginners and offers a good deal of information to enhance coding efficiency.

There are helpful guides to assist with logging defects in Jira, as Maven projects use JIRA for issue tracking, with a complete section as Issue Management under the Maven Community forum. 

Maven community offers a complete Developers Guide, which acts as the documentation center for developers, beginners, as well as seasoned ones, who can refer to the composite structure of information listed there.

Maven offers a public repository that contains projects and can be accessed directly. This acts as a central repository that allows users to know Maven better. The whole idea behind creating such a repository is to enable control over servers at an individual level by providing the desired security. 

Maven comes with additional benefits for its users for better collaboration, such as –

  • Mailing Lists – This is designed to address questions pertaining to Maven and its functionalities. 
  • IRC (Internet Relay Chat) – This is a chat facility that facilitates entering a discussion with an IRC client.