1

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?

FBB
  • 1,414
  • 2
  • 17
  • 29

1 Answers1

0

Turns out that the filtering defined in the maven-war-plugin section is not correctly seen by J2EE preview, I needed to add a resource filtering section:

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <includes>
            <include>myfile</include>
        </includes>
    </resource>  
</resources>

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 by J2EE Preview

FBB
  • 1,414
  • 2
  • 17
  • 29