Search code examples
eclipsemaven-2m2eclipse

Files in src/main/resources not copied when using maven and eclipse


I use maven and eclipse (with m2eclipse) for Java projects. I usually start with

$ mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DgroupId=com.whatever.app \
  -DartifactId=wonderapp
$ mvn eclipse:eclipse

and then import the project into eclipse. The build path in eclipse now contains an "Excluded: **" pattern for the src/main/resource path. If I put for example the log4j.properties file in src/main/resources, it will not be copied to the output path and hence log4j won't work properly.


(source: skitch.com)

After I ran mvn eclipse:eclipse, the .classpath file in the root directory contains this line:

<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>

After importing in eclipse, it has changed to:

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

I end up having to manually remove the "**" pattern. Is there any way so that I don't have to do this?


Solution

  • I use maven and eclipse (with m2eclipse) for Java projects. I usually start with (...) and then import the project into eclipse.

    Why do you use mvn eclipse:eclipse with m2eclipse? Just create your project and then Import... > Existing Maven Project.