I have a Maven WAR project, managed under Eclipse using m2e and m2e-wtp. In my pom.xml, I configure the maven-war-plugin to filter some resources in src/main/resources, and to put them in the classpath.
My files are correctly filtered, both in project/target/finalname/WEB-INF/classes/ and in project/target/m2e-wtp/web-resources/WEB-INF/classes/. However, when I run my webapp using J2EE Preview, the values are read unfiltered.
After investigating, I discovered that the files read, in my webapp launched on the J2EE Preview server, were located in WORKSPACE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/project/WEB-INF/classes/, and that they were unfiltered.
So it seems that m2e-wtp is correctly doing his job here, but that the server adapter somehow messes up the filtering. It seems to acquire the unfiltered resources directly from src/main/resources/, to put them in the .metadata/ dir, instead of acquiring them from project/target/.
How could I make sure that the server adapter acquires the filtered resources?
Turns out that the filtering defined in the
maven-war-pluginsection is not correctly seen byJ2EE preview, I needed to add aresourcefiltering section:In that case, the file is correctly filtered in the directory
WORKSPACE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/project/WEB-INF/classes/, used byJ2EE Preview