What is Apache Maven?

Apache Maven, is a software project management, and comprehension tool, based on the concept of a project object model, or POM. Maven can manage a project’s build, reporting, and documentation from a central piece of information.

A more comprehensive definition of Apache Maven, is that Maven is a project management tool, which encompasses a project object model. It follows a set of standards, it includes a project life cycle, a dependency management system, and logic for executing plugin goals at defined phases in a life cycle. Maven is designed to provide a simple project setup, that uses best practices as a guide.

With Maven, your projects follow a consistent structure. Projects become IDE agnostic, by enforcing a consistent structure, it makes modifications easier in the future, when new developers are introduced to the project. It also ensures that programmers always get the most recent version of compilers, etc.

Most Java projects rely on other projects, and open source frameworks, to function properly. It can be cumbersome to download these dependents manually, and keep track of their versions, as you use them in your project. Maven provides a convenient way to declare these project dependencies, in a separate, external, POM.XML file. It then automatically downloads these dependencies and allows you to use them in your project. This simplifies project dependency management greatly. It is important to note, that in the POM.XML file, you specify the what, and not the how. The POM.XML file, can also serve as documentation tool, conveying your project dependencies and their versions. Software developers refer to Maven, as a build tool. Since it is used to build deployable artifacts from source code. On the other hand, if you asked a project manager they might call it a project management tool, since it follows a development life cycle. In reality, it is both.

Download Maven

To get started using Apache Maven, start by downloading Maven from the maven.apache.org website. From this page we can just use the link in the middle where it says Use Download. Always make sure you download the latest version.

Install Maven on Windows

Now that we have the Maven file downloaded and extracted into our program files directory, we can go ahead and install Maven on our Windows machine. As I stated earlier, the Maven download is not very large. That’s because Maven’s power is included in its plugins which are located and retrieved from a central repository on an as-needed basis and allowing for greater code reuse. Before the installation we must verify our Java version from the command line using java -version. Remember it must be 1.7 or higher.

  1. Install JDK and Add ‘JAVA_HOME’ Environment Variable.To install java, download JDK installer and add/update the JAVA_HOME variable to JDK install folder.
  2. Download Maven and add ‘MAVEN_HOME’ and ‘M2_HOME’ Environment Variables. Maven can be downloaded from this location. Set the M2_HOME and MAVEN_HOME variable to maven installation folder.

3. Include ‘maven/bin’ directory in ‘PATH’ variable. To run maven from command prompt, this is necessary. Update the PATH variable with ‘Maven-installation/bin’ directory.

4. Verify maven in console:

Maven installation is complete. Now lets test it from windows command prompt.

  1. Go to start menu and type cmd in application location search box.
  2. Press ENTER. A new command prompt will be opened.
  3. Type mvn -version in command prompt and hit ENTER.

#apache #automation #build #maven #java

Java: Build Automation With Maven
1.30 GEEK