Book Image

Apache Maven Cookbook

By : Raghuram Bharathan
Book Image

Apache Maven Cookbook

By: Raghuram Bharathan

Overview of this book

If you are a Java developer or a manager who has experience with Apache Maven and want to extend your knowledge, then this is the ideal book for you. Apache Maven Cookbook is for those who want to learn how Apache Maven can be used for build automation. It is also meant for those familiar with Apache Maven, but want to understand the finer nuances of Maven and solve specific problems.
Table of Contents (13 chapters)
12
Index

Introduction

Apache Maven is a popular tool for build automation, primarily Java projects. Maven addresses two aspects of building software. First, it describes how a software is built and, second, it describes its dependencies. It uses conventions for the build procedure. An XML file describes the software project being built, its dependencies on other external modules and components, the build order, directories, and required plugins. It comes with predefined targets to perform certain well-defined tasks, such as code compilation and its packaging. Maven dynamically downloads Java libraries and Maven plugins from one or more repositories, such as the Maven Central Repository, and stores them locally.

Ever since Maven 1.0 was released in 2004, it has gained popularity and is today the build tool for a large number of open source and commercial projects.

If you are reading this book, then you are not here to understand why Maven is required. You are here to explore Maven and unleash the potential that it offers. The objective of this book is to make the reader aware of Maven's various features, which include installation, configuration, and simple to complex usage by means of examples, illustrations, and working projects.

A brief comparison with other build automation tools

Let's briefly discuss some build automation tools:

  • Make: If you are from the C programming world, chances are you have used Make. Makefiles are not platform-independent. They are not natively compatible with Windows. Thus, they are unsuited to build Java projects.
  • Ant: This is modeled after Make and has targets and dependencies. Each target has a set of tasks. Ant doesn't have any conventions. It is procedural and does not have the concept of a build lifecycle. Maven has conventions, is declarative, and has a lifecycle.

In this chapter, we will cover the basics of Maven—installing the software, verifying the installation, and creating, implementing, and building a simple Java project. We will also cover a few advanced items, such as changing the location of the repository or running Maven behind an HTTP proxy server as it could be relevant to those who have issues with the way Maven works by default.

Let us start by setting up Maven. We will cover how to do this on the three popular operating systems, namely Microsoft Windows, Mac OS X, and Linux.