How do I filter resource files to include the values of properties?
Author: Deron Eriksson
Description: This tutorial describes how to filter resource files in maven.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)

Page:    1 2 >

Resource files can contain references to properties (in the form ${...}). By default, at build time mavenSW doesn't resolve these values. However, it's possible to filter resource files to resolve property values by specifying build.resources.resource.filtering to be 'true' in your pom.xml file. If you do this, you also need to explicitly specify the, as shown in the pom.xml file below.


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

My project contains the following resource file, textfile.txt, that contains a reference to the project.artifactId property.


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

I'll perform a "mvn clean process-resources" to process the resource files in the project. The "process-resources" is a phase in the maven default lifecycle.

Executing 'mvn clean process-resources' on 'aproject'

The following console output is generated as a result of the "mvn clean process-resources"

Console output from 'mvn clean process-resources' on 'aproject'

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building aproject
[INFO]    task-segment: [clean, process-resources]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory C:\dev\workspace\aproject\target
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Feb 15 17:21:20 PST 2008
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------

(Continued on page 2)

Page:    1 2 >