Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with Eclipse and a Maven multi-module project

I have created a Maven project with the following structure:

+ root-project
  pom.xml (pom)
  + sub-projectA (jar)
  + sub-projectB (jar)

I have done the following steps:

  1. mvn archetype:create –DgroupId=my.group.id –DartifactId=root-project
  2. mvn archetype:create –DgroupId=my.group.id –DartifactId=sub-projectA
  3. mvn archetype:create –DgroupId=my.group.id –DartifactId=sub-projectB

So I have, obviously, in the top-level pom.xml the following elements:

  <modules>
    <module>sub-projectA</module>
    <module>sub-projectB</module>
  </modules>

The last step was:

mvn eclipse:clean eclipse:eclipse

Now if I import the root-project in Eclipse, it seems to look at my projects as resources and not like java projects.

However if I import each of child projects sub-projectA and sub-projectB, it looks them like java projects.

This is a big problem for me because I have a deeper hierarchy. Any help would be appreciated!

like image 688
earth Avatar asked Jun 10 '10 15:06

earth


People also ask

Does Eclipse work with Maven?

The Eclipse IDE provides support for the Maven build. This support is developed in the M2Eclipse project. It provides an editor for modifying the pom file and downloads dependencies if required. It also manages the classpath of the projects in the IDE.

What is the difference between Java project and Maven project in Eclipse?

Eclipse internal build (Eclipse's Build Project or Build All or Clean) and Maven/Ant build basically do the same thing which means that they both will compile the source code file. Now an obvious difference is that Eclipse internal build will not generate EAR, WAR etc. files for you, which you do using ANT/Maven.


1 Answers

The maven eclipse plugin does NOT support nested projects so you can't import the root-project and the nested modules (unless you move to a flat layout).

The alternative is to use m2eclipse (and you won't have any problems with a maven-typical nested tree). This is the preferred approach nowadays.

like image 169
Pascal Thivent Avatar answered Oct 23 '22 11:10

Pascal Thivent