Reputation: 39323
I have a maven project that I correctly build through the command line (mvn test
). It is structured this way:
pom.xml
|-------subdir1/pom.xml
|-------subdir2/pom.xml
|-------subdir3/pom.xml
Inside each of the subprojects dir (subdir[1-3]), I have a structure of:
src/main/java
src/test/java
When I import the project to Eclipse, or update the maven configuration (Alt-F5), the src
dirs are incorrectly added to the BuildPath. I always need to manually remove them and add each one of the java
dirs to have Eclipse correctly compiling.
How do configure my project so Eclipse will always correctly add the build paths?
Upvotes: 4
Views: 1358
Reputation: 4498
Just to add a point, I used to get similar issues with eclipse while importing maven project, you can run this from cmd prompt mvn eclipse:clean
mvn eclipse:eclipse
and then refresh or right click->maven->update your project in eclipse.
Also some times eclipse doesn`t import projects properly, you can just remove it from workspace and add again.
Upvotes: 2
Reputation: 39323
Ops, silly me. A colleague of mine added to the pom a spurious configuration:
<build>
<sourceDirectory>src</sourceDirectory>
I just removed it from the configuration to use maven convention and everything worked fine. Thanks for the help.
Upvotes: 5
Reputation: 9616
Ensure the following in root pom.xml:-
<modules>
<module>subdir1</module>
<module>subdir2</module>
<module>subdir3</module>
</modules>
Then in each of the subdirX/pom.xml add parent tag similar to the following. make sure parent coordinates are correct:
<parent>
<groupId>your-parent-groupId</groupId>
<artifactId>your-parent-artifactid</artifactId>
<version>1.0</version>
</parent>
Upvotes: 0