Sunday, February 5, 2012

Git, Eclipse and Maven multi-module project

More adventures in maven (sometimes I wonder how worth it is with maven), git and Eclipse...

So I have a multi-module maven project I'm working on, something of prototype to use for future reference for Maven managed EAR projects, and I'm using git for version control. I'm used to using SVN in Eclipse (via Subclipse) and CVS of course, unfortunately, but git's a little different. After some experimentation I think I've got things setup so that

A) the parent and each of the sub projects are connected to the same working git repo within Eclipse and
B) the Eclipse project settings are all managed by maven & the m2e plugins so that none of the Eclipse files (or dependency jars! ;) are checked into source control.

No real need there on that second point, just a preference since maven is so uber magically cool (</sarcasm>) and it handles all the gnarlly Eclipse project set up for you. If you like using other editors, this way you don't have all the Eclipse trash to deal with when you check the project out. Plus I like to hurt myself sometimes proving maven can do it a couple of times a year. Usually after a weekend, like this one, I have things worked out and it is actually pretty cool.
So when it comes to version control, to get everything set up and working using git I am doing the following:

  • Clone the project into my active workspace, either by command line or via the Eclipse egit wizards.
  • Import the existing maven projects into my workspace
  • Connect each of the imported projects to the git repo I'm working out it by right clicking on the project and choosing Team > Share Project > selecting Git then finally checking the "Use or create repository in the parent folder" check box. This can be done in bulk by selecting multiple projects

  • Now I have my nice snazzy maven/m2e managed multi-module project and all the flexible goodnes that comes with it, at least twice as much as needed to hang my self multiple times a day for a year, connected to git so I can check things in locally and forget to push the changes up to the bare repo I cloned from ; ) Good times.

    1 comment: