Maven web resources filtering


Problem: How to perform maven filtering for resources inside webapp

Solution: To acheive this, we need to add the below plugin inside pom.xml and include the resources that need to be filtered, in this example, its *.html

<!– Enabling and configuring web resources filtering –>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/*.html</include>
<!– include any other file types as needed –>
</includes>
</resource>
</webResources>
</configuration>
</plugin>

once the resources are filtered, pom specific settings will be available in the html, for example version of the project can be accessed from the html as ${project.version}

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: