O'Reilly logo

Maven: The Definitive Guide by Sonatype Company

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Maven Properties

You can use Maven properties in a pom.xml file or in any resource that is being processed by the Maven Resource plugin’s filtering features. A property is always surrounded ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required