Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse + Maven + Git + Multi-Module projects = Unhappiness

We've got a multi-module project using Eclipse and Maven. The only way I could get it to work in the past was to use a flat layout for the projects, where the parent module was a peer to the other modules. This worked fine with m2eclipse and Subversion.

Now we'd like to move to Git and GitHub. I'd like to expose the entire project, along with all the modules, as a single project on GitHub. The problem is that EGit, the Eclipse/Git plugin, wants to manage projects one at a time, not groups of projects, and so if you've got a flat layout, you can't do it.

The right answer is to use a standard Maven hierarchical layout and manage the parent and all the modules as a unit. But Eclipse doesn't like that, and no amount of fiddling will get Eclipse to accept nested projects. m2Eclipse does not support hierarchies: https://issues.sonatype.org/browse/MNGECLIPSE-2291

So what do you do? Do Git from the command line and abandon the ability to see what files have changed in Eclipse? Or abandon Eclipse?

like image 978
ccleve Avatar asked Oct 20 '11 19:10

ccleve


1 Answers

A standard Maven multi-module structure as a single git repo works perfectly fine for me in Eclipse Indigo with M2e and the git plugin that shows up in that environment. You can't ask Eclipse to do your fetching for you, but once you've pulled from command line, you use Team/Share, say 'Git!' and all is well.

I think I see what's the source: hierarchy is a problem for projects inside the workspace, not 'existing projects' that you import.

Here's a typical workflow:

  1. use git svn clone to get a tree. it's a stock, hierarchical mvn multi-module tree
  2. in eclipse, use import/maven/existing maven project. Point at the whole tree
  3. select all
  4. OK

it works fine. The nesting does not disturb eclipse one bit. I don't know what problem that bz is pointing at.

Before I used m2e I used the maven-eclipse-plugin. And it also worked in these cases, because it does not generate a .project/.classpath for <packaging>pom</packaging> aggregating projects, so Eclipse is never called upon to actually nest anything.

I'm not alone -- see the developer setup instructions as cxf.apache.org for an open source example that you can try for yourself.

like image 157
bmargulies Avatar answered Sep 27 '22 16:09

bmargulies