Search code examples
javaeclipsemaven-2m2eclipsebuildpath

m2eclipse buildpath mess up


Being a newbie with maven, I've set up a new project with the archetype "webapp" and try to build from that.

My project structure is as follow : src/main/resources for production classes, and src/main/test for unit tests. Everything is working fine but when i use the m2eclipse menu "update project configuration", the build-path mess up ... It seems to me that eclipse doesn't recognize anymore my packages "com.example". Files are still in src/main/resourceS/com/example, but it says "the resource is not in the build path".

When i try to configure the project build-path, i notice that the parameter "Excluded" is set to ** for both source folders ... If i remove the ** token and set the exclusion filter to "none", errors in files disappear but the package mess up and eclipse want to force the test files in the default package ...

Any help with eclipse build-path and maven much appreciated,

Thanks


Solution

  • My project structure is as follow : src/main/resources for production classes, and src/main/test for unit tests.

    This is not correct, sources should go in src/main/java. See Introduction to the Standard Directory Layout for some guidelines about Maven defaults.

    Everything is working fine

    I highly doubt "everything" is working fine. With your current setup, sources simply won't be compiled.

    but when i use the m2eclipse menu "update project configuration", the build-path mess up...

    It's your project setup that is messed up. Put sources in src/main/java.

    When i try to configure the project build-path, i notice that the parameter "Excluded" is set to ** for both source folders ... If i remove the ** token and set the exclusion filter to "none", errors in files disappear but the package mess up and eclipse want to force the test files in the default package ...

    If your maven project is properly set up, m2eclipse will derive a proper eclipse configuration from it. You don't and you shouldn't have to change anything manually.