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

前端 未结 4 2231
别跟我提以往
别跟我提以往 2021-02-19 23:21

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

相关标签:
4条回答
  • 2021-02-19 23:29

    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 
    
    0 讨论(0)
  • 2021-02-19 23:34

    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.

    0 讨论(0)
  • 2021-02-19 23:49

    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.

    0 讨论(0)
  • 2021-02-19 23:55

    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

    0 讨论(0)
提交回复
热议问题