Search code examples
mavenclasspathm2eclipsem2e

How can I get m2e plugin to ignore resource filtering when writing eclipse .classpath


When m2e(1.1.0) in eclipse(indigo) updates project configuration it changes the entry for my resources folder to exclude all.

<classpathentry excluding="**" kind="src" output="target/classes" path="conf"/>

But I need the following for tests to run successfully:

<classpathentry kind="src" output="target/classes" path="conf"/>

I want to exclude some resources from my jar (e.g., license.foo) but I need many of these files to be on the eclipse classpath to enable test execution.

What's the right approach to resolve this problem?

  • Are there settings to org.eclipse.m2e in my pom to change the behavior?
  • Can I add text to the .project/.classpath to inform m2e that this must remain?
  • Should I use profiles to alter what gets stored in the jars?

How have you approached this class of problem? (FYI this is similar to MNGECLIPSE-864)

Thanks

Peter


Solution

  • You should place resources that you need at runtime to

    src/main/resources
    

    and resources that you only need for testing to

    src/test/resources
    

    This is the Maven Standard Directory layout and the resources will be on the classpath.

    If you have not standard directories you should use the Maven Build Helper Plugin to add additional (test) resource directories.