Question

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

Was it helpful?

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.

OTHER TIPS

If you run into this problem then you might want to ask "why would I want eclipse and command line maven to handle resources differently."

I assumed this problem grew out of a desire to keep unwanted items (e.g., license file) out of the shipping jar. However, as FrVaBe point's out about test resources nicely satisfy this need.

I did some digging through assembly files and poms to find out that rival specifications between them moved the conf directory into target/classes, ignored it and imported the original-source location into the pom. I unwound the complexity and have a simpler pom which handles resources in a more standard way.

Thanks for the help

Peter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top