How do I filter resources based on values from a properties file?
Author: Deron Eriksson
Description: This tutorial describes how to filter resources based on properties in a file.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)

Page:    1 2 >

In another tutorial, we saw how we could filter resource files so that we could replace references to properties with the values of those properties and how this substitution takes place during the "process-resources" default lifecycle phase. We can also specify properties in a properties file and use these properties in the substitutions during the "process-resources" lifecycle phase.

For example, suppose we have the following resource file.


this is a test
artifact id: ${project.artifactId} ${}

The project.artifactId property value comes from the project's pom.xml, but we'd like the to be specified in a properties file, such as the following:

src/main/filters/ and fries

The project containing the resource file and the filter properties file are shown here:

Project structure

Here is the project's pom.xml file. It specifies to use the properties in the file via the build.filters.filter value. It specifies to turn on filtering by setting build.resources.resource.filtering to true. It specifies the resource directory via the (this is needed since we overrid the default behavior by setting filtering to true).


<project xmlns="" xmlns:xsi=""

(Continued on page 2)

Page:    1 2 >