Importing multimodule maven project from Git into Eclipse/STS

1.4k Views Asked by At

I have been desperately trying to import a multimodule maven project from GIT into my (freshly installed) STS 3.9.4. During the last hours I tried lots of solutions that were posted on stack overflow, but none of them worked for me.

These are the steps I did:

  • git cloned the repo from the command line (intentionally, because it didn't work either when I used the GIT integration of STS)
  • imported the project via File / Import / Maven / Existing Maven Projects

After the project was imported, it looks like this: Project structure

(please ignore the red icon at the top left, the problems persists even when this icon is not there)

I can Run As / Maven Install any pom.xml, but when I try to edit java sourcecode Eclipse tells me The resource is not on the build path of a Java project. To fix this I tried:

  • convert to faceted form
  • added Java nature
  • Configure Build Path / Set as source folder
  • add buildcommand org.eclipse.jdt.core.javabuilder to .project

Being able to build is fine, but editing sourcecode without support for Organize Imports, Format Source, and so on is a real pain.

2

There are 2 best solutions below

0
Marged On BEST ANSWER

The solution to this problem was somehow hidden, but in the end I have to say the reason was clear. After I checked with a different multimodule project (https://github.com/Activiti/Activiti.git), I was sure that my STS and other components don't suffer from a generic problem. So the cause must be located in the project itself.

The multimodule project was setup correctly on the pom.xml level. But the topmost pom.xml was modified: most of the modules had been commented out: commented out modules in pom

The developer who introduced that change didn't experience any problems because he kept his already existing workspace. And the problem only occurs when a new workspace gets created and maven scans the pom files.

0
Till Brychcy On

From your screenshot I assume the modules are nested within the directory of the reactor pom(=parent pom) and you have imported all of them as projects (reactor and modules).

Don't add a java builder to the "reactor" project.

Make sure not to open the java files from the projects corresponding to the reactor pom, but from src folder within the corresponding module projects.