views:

59

answers:

1

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.

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?

+2  A: 

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.

Pascal Thivent
Good point. I never thought about it. I suppose I have done it this way out of habit, because I started with just maven and eclipse and only later learned about m2eclipse. Anyway, it doesn't seem to matter which import I use. The result with "Import Existing Maven Project" is the same.
bromfiets
+1. Learned that I don't have to use `mvn eclipse:eclipse`
bromfiets
@bromfiets If you import your project as a Maven project, the Maven builder *is* handling resources (which makes filtering possible) and they actually get copied to `target/classes`. In other words, things just work.
Pascal Thivent
Thanks for clarifying the difference between `mvn eclipse:eclipse` and "Import Maven Project". I also saw your answer to question 2061094 which was very helpful. For some reason I ended up in situations where the resources where not copied to `target/classes` and removing the ** exclude pattern reliably fixed this. However, I now have difficulties reproducing this behaviour.
bromfiets
+1 (for this and [question 2061094 which is here](http://stackoverflow.com/questions/2061094)). Congrats in advance for making it to 100K today ;) (in only a year! took me 2 ;) )
VonC
@VonC Thank you very much. Next one now :)
Pascal Thivent