Maven is a build automation and management tool developed by Apache Software Foundation. The name maven means “accumulator of knowledge” in Yiddish language. The development of maven was started by Jason van Zyl as a sub-project of Apache Turbine in 2002. The initial release of maven was released as an Apache Software Foundation project on 13 July 2004. Maven can be considered as similar tools to Apache Ant, Gradle but much more advanced than Ant. It is written in Java and can be used to manage projects written in C#, Ruby, Scala, and many other languages. Maven is based on POM (Project Object Model) which is an XML file that contains information of project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals etc.
What is a build tool?
In small software development projects, developers will often manually invoke the whole build process. But as the projects get more complex the build process also gets complex enough to make it harder for developers to manually manage the build process. Adding dependencies, creating project structure, deploying the project are complex in large software projects. This is where the build tools/ build automation tools come into play. Build tools make the whole build process more efficient and consistent by automating most of the complex steps with very little human interaction.
The following image represents the architecture of Apache Maven 3.x.
These are the key futures of Maven according to Apache itself,
· Simple project setup that follows best practices — get a new project or module started in seconds.
· Consistent usage across all projects — means no ramp-up time for new developers coming onto a project.
· Superior dependency management including automatic updating, dependency closures (also known as transitive dependencies)
· Able to easily work with multiple projects at the same time.
· A large and growing repository of libraries and metadata to use out of the box, and arrangements in place with the largest Open-Source projects for real-time availability of their latest releases.
· Extensible, with the ability to easily write plugins in Java or scripting languages.
· Instant access to new features with little or no extra configuration.
· Ant tasks for dependency management and deployment outside of Maven.
· Model-based builds: Maven can build any number of projects into predefined output types such as a JAR, WAR, or distribution based on metadata about the project, without the need to do any scripting in most cases.
· Coherent site of project information: Using the same metadata as for the build process, Maven can generate a web site or PDF including any documentation you care to add and adds to that standard reports about the state of development of the project. Examples of this information can be seen at the bottom of the left-hand navigation of this site under the “Project Information” and “Project Reports” submenus.
· Release management and distribution publication: Without much additional configuration, Maven will integrate with your source control system (such as Subversion or Git) and manage the release of a project based on a certain tag. It can also publish this to a distribution location for use by other projects. Maven can publish individual outputs such as a JAR, an archive including other dependencies and documentation, or as a source distribution.
· Dependency management: Maven encourages the use of a central repository of JARs and other dependencies. Maven comes with a mechanism that your project’s clients can use to download any JARs required for building your project from a central JAR repository much like Perl’s CPAN. This allows users of Maven to reuse JARs across projects and encourages communication between projects to ensure that backward compatibility issues are dealt with.
Project Object Model (POM)
A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. Each project made with Maven contains this file. Some of the details in the XML file includes project name, version, package type, dependencies, Maven plugins, etc. The POM can be very complex and huge. But you do not need to worry about all the small details in the file to use it effectively.
A simple pom file might look like this:
Maven is a build automation and management tool developed by Apache Software Foundation. Developers can create well-structured projects easily with the use of Maven tool. The pom.xml file is the core of a project’s configuration in Maven.