Chapter 13. Properties and Resource Filtering

Introduction

Throughout this book, you will notice references to properties that can be used in a POM file. Sibling dependencies in a multiproject build can be referenced using the ${project.groupId} and ${project.version} properties, and any part of the POM can be referenced by prefixing the variable name with “project.” Environment variables and Java System properties can be referenced, as well as values from your ~/.m2/settings.xml file. What you haven’t yet seen is an enumeration of the possible property values and some discussion about how they can be used to help you create portable builds. This chapter provides such an enumeration.

If you’ve been using property references in your POM, you should also know that Maven has a feature called resource filtering that allows you to replace property references in any resource files stored under src/main/resources. By default, this feature is disabled to prevent accidental replacement of property references. This feature can be used to target builds toward a specific platform and to externalize important build variables to properties files, POMs, or profiles. This chapter introduces the resource filtering feature and provides a brief discussion of how it can be used to create portable enterprise builds.

Get Maven: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.