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

时间秒杀一切 提交于 2019-12-04 00:43:47

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.

Is it possible that you are working with old versions of the tool?

I have a Maven multi-module project that I work with using Eclipse 3.7 (Indigo), M2Eclipse (1.0) and EGit (1.0).

On the file system the multi-module project has a single parent directory.

In Eclipse I have separate projects for each module.

M2Eclipse does the dependency management perfectly.

There is single git repository (.git directory) at the top-level and EGit works perfectly.

You can put your modules in Git with hierarchical layout. And build those modules by Maven. If those modules are projects(whatever java, c++ or php project) recognized by Eclipse, they can be imported into workspace as flat layout in workspace.

-- the root of Git working directory
  -- moudule1
    -- project1(a java project)
      -- .project(a project file recognized by eclipse JDT)
      -- pom.xml
    -- project2(a java project)
      -- .project
      -- pom.xml
  -- module2
    -- projectA(a java project)
      -- .project(a project file recognized by eclipse JDT)
      -- pom.xml
    -- projectB(a c++ project)
      -- .project(a project file recognized by CDT)
      -- pom.xml 

For Maven projects, multiple imports at once can be achieved via the Maven import wizard (that is accessible from Git). In case you don't know what kind of projects you're about to import, you can use the new Easymport that will import project "as best", by deducing configurations from various files. See https://github.com/jbosstools/jbosstools-playground#easymport-easy-and-smart-openimport-of-a-project

Once you get all those projects, you can use the Nestor plugin, which will show project in a nested/hierarchical layout, mapping more correctly your Maven project: https://github.com/jbosstools/jbosstools-playground#nestor-view-nested-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!