Apache Maven is one of the most popular project management tools in the Java world.

Developed as a build automation tool for Java projects, Apache Maven is much more powerful and user friendly than Think of Ant, or Make.

Have you ever had to deal with building a Java project?

You have probably dealt with the many frustrations that Maven is designed to eliminate — especially if your Java project has dependencies or special build requirements.

The fundamental unit in Maven is the project object model (POM), an XML file that includes information about the software project; configuration details that Maven uses in building this project; and any dependencies on external components or modules and the build order.

Much of Maven's functionality depends on plug-ins, which provide a set of goals that can be executed. In fact, all work is handled by plug-ins. There are numerous Maven plug-ins for building, testing, SCM, running a Web server, and more. Plug-ins are configured in the POM file. Some basic plug-ins are included by default.

Here we will discuss the functionality of Maven as well as how to properly download and install it.

That’s So Maven

Maven Logo

Maven was created by Jason Van Zyl in 2002 as part of the Apache Turbine project. Maven has been an open source project under the Apache umbrella since 2003.

Spend some time researching Maven, and you will see that it is no wonder Maven has enjoyed consistent, enthusiastic backing and unwavering popularity. It is a very stable and feature-rich tool.

Maven offers a plethora of useful plugins that can do anything from exporting PDF versions of your project's documentation to creating a list of recent changes from your SCM.

To accomplish these handy functions, all you need to do is add a small amount of extra XML, or an additional command line parameter here and there.

If you have a lot of dependencies, you definitely need to check out Maven.

Maven connects to remote repositories (or you can set up your own local repos), then automatically downloads all of the dependencies needed to build your project.

For example, maybe you have a project that uses a Apache's Camel routing tool, such as version 2.10.6. Then, a new version of Camel is released. Instead of having to go to the Apache website, download the 2.11.1 distribution, the replace 2.10.6 with the new version, you can just tell Maven to use the new distribution, and the work will be done automatically.

That is Maven!

Think about having to perform all of the updates for multiple dependencies every time one is updated.

No doubt, Maven is a time-saver.

Maven is as Maven Does

Apache Maven website

Once you get familiar with a few of the main concepts of Maven, you will find that it is extremely easy to use. Each project contains a file called a POM (Project Object Model).

A POM is basically an XML file containing details of the project, such as the project name, version, package type, dependencies, and Maven plugins.

Features include:

  • A standard, easy way to build projects in which unnecessary details are hidden.
  • A uniform build system, where a standard strategy is followed when building any project.
  • Quality project information, such as dependency lists, cross referenced sources and unit test reports.
  • Dependency management, including automatic updating and dependency closures.
  • The ability to handle multiple projects simultaneously.
  • Dynamic downloading of necessary Java libraries and plug-ins from Maven repositories.

System Requirements for Maven

  • Java Development Kit (JDK): Maven 3.3+ require JDK 1.7 or above to execute. They still allow you to build against 1.3 and other JDK versions by using Toolchains
  • Memory: No minimum.
  • Disk: Approximately 10MB is required for the Maven installation. In addition to that, more disk space will be used for your local Maven repository. The size of your local repository will vary depending on the usage, but expect, at least, 500MB.
  • Operating System: No minimum requirement. Start up scripts are included as shell scripts and Windows batch files.

Maven is distributed in several formats for your convenience. Simply pick a ready-made binary distribution archive, then follow the installation instructions.

We advise that you use a source archive if you intend to build Maven yourself.

In order to guard against corrupted downloads/installations, it is highly recommended to verify the signature of the release bundles against the public KEYS used by the Apache Maven developers.

Downloading Apache Maven 3.5.4

maven design

Apache Maven 3.5.4 is the latest release, and the recommended version for all users.

We strongly recommended that you use the latest release version of Apache Maven to take advantage of the newest features and updated bug fixes.

The currently selected download mirror is http://www-eu.apache.org/dist/.

If you happen to encounter a problem with this mirror, please select another mirror. If all mirrors are failing, you may consult the complete list of mirrors as well.

Installing Maven on Windows

To install Maven on Windows, go to the Apache Maven site to download the latest version. Select the Maven zip file — for example apache-maven-3.3.9-bin.zip.

Unzip it to the folder you want Maven to live.

If you want to add Maven to the environment path, add both M2_HOME and MAVEN_HOME variables to the Windows environment using system properties. Then, point it to your Maven folder.

Next, update the PATH variable by appending the Maven bin folder – %M2_HOME%\bin, so that you can run the Maven’s command everywhere.

To verify it run “mvn - version”.

After that, you are good to go.

Installing Maven on Mac OS X

To install Maven on Mac OS X operating system, download the latest version from the Apache Maven site, select the Maven binary tar.gz file, for example: apache-maven-3.3.9-bin.tar.gz.

Extract the archive to your desired location.

Installing Maven on Linux

To install Maven on the Linux operating system, download the latest version from the Apache Maven site, select the Maven binary tar.gz file, for example: apache-maven-3.3.9-bin.tar.gz.

Extract the archive to your desired location.

13 Key Features Every Maven User Needs to Know

apache maven

Maven allows the developer to automate the process of the creation of the initial folder structure for the Java application, performing the compilation, testing, packaging and deployment of the final product. It is implemented in Java which makes it platform-independent. Java is also the best work environment for Maven.

  1. Maven allows for a straightforward project setup in seconds.
  2. Very little time spent for new developers joining project.
  3. Dependency management: automatic updating, and transitive dependencies.
  4. You can easily work with multiple projects at the same time.
  5. A impressive repository of libraries and metadata ready to use. Maven has access to the largest open source projects for real-time availability of their latest releases.
  6. You can write plugins in Java or scripting languages.
  7. Instant access to new features without a lot of extra configuration.
  8. For dependency management and deployment outside of Maven, use Ant tasks.
  9. Multitasking: Maven is able to build many projects into predefined output types such as a JAR or WAR. Also, you can rely on distribution based on metadata about the project without the need for scripting.
  10. Coherent site of project information: Using the same metadata as the build process, Maven is able to generate a web site or PDF, including any documentation you care to add.
  11. Release management and distribution publication: Maven integrates with your source control system, and manages the release of a project based on a particular tag. Also, it can publish to a distribution location for use by other projects.
  12. Maven is able to publish individual outputs such as a JAR, archives including other dependencies and documentation, or as a source distribution.
  13. Dependency management: 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. Maven encourages the use of a central repository of JARs and other dependencies.

Install Maven and Optimize Your Workflow

Critics of Maven point to several downsides. For instance, they say Maven is a bit complex. There is a learning curve, and your project needs to be laid out the correct way for best results. you can work around this but you shouldn’t. And, if you have a dependent JAR that isn't “mavenized”, you will struggle integrate it.

Across the board, developers feel that Maven is easy to use, compared to Ant. They say it is very fast and certainly flexible. You can manage all your dependencies, your group projects, track your application build and deployment in a single place.

Sharing your projects with your team will be made much easier with Maven.

Also, reducing the number of huge files you have to attach is a plus, and you don't need to worry if your colleague is using a different version of a dependency. Maven will ensure everyone has the same scenario to work on.

Download, and install Maven. You won’t regret it.