Problem with Eclipse and a Maven multi-module project
Asked Answered
P

3

9

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!

Paranoiac answered 10/6, 2010 at 15:56 Comment(0)
I
6

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.

Indorse answered 10/6, 2010 at 18:1 Comment(2)
The link to m2eclipse is not working. Do you have an updated link? The eclipse.org link I find after searching is not working as you described.Anomie
The M2Eclipse project now resides at www.eclipse.org/m2e. Also, M2Eclipse comes preinstalled with many Eclipse packages, e.g., the Eclipse IDE for Java (EE) Developers.Vernverna
W
0

Please follow these simple step's to configure project

  1. Download project from maven project

  2. Inside ch-multi-spring->simple-parent

convert simple-parent to eclipse project using this command

mvn eclipse:eclipse
  1. Import sample-parent in eclipse.

  2. For runing this project

    right click on simple-webapp->properties->deployment assemblly->project-> Then add all the dependent project.

  3. Now you can run this project.

Woodworth answered 5/7, 2013 at 10:40 Comment(0)
P
0

I had a similar issue, and the following is what I did to solve it...

I had the parent project open as well as the child projects. The child projects would build fine and not show any problems, however the parent showed the child projects as "resource folders" and they showed as having problems.

Solution was to right click on each of the child projects in the parent project -> Properties -> Resource -> Check "derived"

After you do this, clean/rebuild and you should be good.

Phail answered 11/7, 2017 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.