Chapter 1. Getting Started

In this chapter, we will cover the basic tasks related to getting started with Apache Maven:

  • Installing Maven on Microsoft Windows
  • Installing Maven on Mac OS X
  • Installing Maven on Linux
  • Changing the JDK used by Maven
  • Creating a simple project with Maven
  • Building a simple project with Maven
  • Changing the location of the Maven repository
  • Running Maven behind an HTTP proxy server
  • Understanding the standard directory layout

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.35.247