You are previewing Maven: The Definitive Guide.

Maven: The Definitive Guide

Cover of Maven: The Definitive Guide by Sonatype Company Published by O'Reilly Media, Inc.

Chapter 11. Build Profiles

What Are They For?

Profiles allow for the ability to customize a particular build for a particular environment; profiles enable portability between different build environments.

What do we mean by different build environments? Two example build environments are production and development. When you are working in a development environment, your system might be configured to read from a development database instance running on your local machine, whereas in production your system is configured to read from the production database. Maven allows you to define any number of build environments (build profiles) that can override any of the settings in the pom.xml. You can configure your application to read from your local, development instance of a database in your “development” profile, and you can configure it to read from the production database in the “production” profile. Profiles can also be activated by the environment and platform; you can customize a build to run differently depending on the operating system or the installed JDK version. Before we talk about using and configuring Maven profiles, we need to define the concept of “build portability.”

What Is Build Portability?

A build’s “portability” is a measure of how easy it is to take a particular project and build it in different environments. A build that works without any custom configuration or customization of properties files is more portable than a build that requires a great deal of work to build ...

The best content for your career. Discover unlimited learning on demand for around $1/day.