Maven filtering – replacement of variables

I have a maven project, which generates a jar file as a web project. Based on Maven I include a standalone Tomcat. Inside of the jar file, there is actually the war-file, which contains my application.

This application contains a “version.txt” in src/main/config (or any similar path), that is finally included in the war-file.

This version.txt looks like:

version: ${project.version}

I would like, that maven should replace the variable with the correct version from pom.xml. In my pom.xml I have included:


So is there any way to include this version.txt and a working replacement in a war-file, which is in a (Tomcat)jar-file?


My File hierarchy looks like:

-- ...
---- ...


I suggest you use the maven-war-plugin.

It will expect a certain directory layout, and in the examples it clearly shows how to filter (replace maven variables into the web resources)

If this solution falls short, then a more specific question based on this should should be asked later.