I have the impressions that we put 2 different things under the “resource filtering” concept.
src/main/resources folder contains files that should be available on the classpath (to allow finding them with
myClass.getResources()), but that should not be considered as source code. For example Eclipse should not try to compile
.java files under
src/test/resources, and also probably not validate all
.js files in
node_modules. The problem is that in Eclipse, there is no concept of “resource” folder. So there is a need to tell Eclipse to “filter” some files from being processed by the auto-build.
variable substitution during resource files processing. This is called “filtering” in Maven, and I think this is why this is confusing. In Gradle we are using something like:
filter ReplaceTokens, tokens: [
In Eclipse, we wants to ensure that at runtime (like when running JUnit tests) the classpath contains the “resolved” resources, not the original ones.
I remember m2e spent a lot of time trying to find a working solution, that would not trigger recursive auto-builds.
When importing a Maven project into Eclipse with m2e, resource folders have all their content excluded:
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
It means Eclipse will not touch resources files at all. I guess the Maven Builder will take care to copy resources to the output folder, applying variable substitution if needed. I think the Gradle Builder could do the same.