Book Image

Apache Maven Cookbook

Book Image

Apache Maven Cookbook

Overview of this book

Table of Contents (18 chapters)
Apache Maven Cookbook
About the Author
About the Reviewers

Using properties in Maven

Maven allows us to define as well as use properties. Properties allow us to avoid hardcoding values in multiple places such as versions of dependencies. They also provide flexibility to the build tool by allowing values to be passed at runtime.

How to do it...

Let's define and use Maven properties by performing the following steps:

  1. Open the pom file of a project that we created earlier.

  2. Define a property:

  3. Use the property:


How it works...

There are different types of properties. They are as follows:

  • Environment variables: Prefixing a variable with env. will return the value of the shell's environment variable. For example, ${env.PATH} will return the value of...