views:

20

answers:

3

Hi,

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

A: 

Your project need to be buildable from the command line, i.e. have a valid pom.xml with packaging war and you need to have WTP and Maven integration for WTP installed to work with the web projects.

Resources are excluded from build path to allow Maven builder filter them. You shouldn't remove that exclusion.

Eugene Kuleshov
A: 

Hello,

You say that your Java files are located in src/main/resources? This is not the correct place to put your Java classes. The correct path is src/main/java.

Here is the conventions for paths with Maven 2 / 3.

romaintaz
+1  A: 

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.

Pascal Thivent
Thanks for the quick response. I moved my files in srv/main/java and the problem disappear !
Balistick