Seva's notes

Wisdom, Awareness, Responsibility :)

Eclipse Maven Integration

with 4 comments

Honestly, I was pretty unsure regarding Maven at all. “Why should I port my projects from Ant, where everything is plain, simple and predictable? Single point integration jars are connected to their dependent projects, shared ones are extracted to a Libraries project. Deployment is as easy as checkout and build…” – I convinced myself.

But soon I’ve realized that if our team’s Product is no more than a chain in the string of Products and Components which are unified into the Solution, than why the hell should our code base not to be like that? It’s so nice that lots of Environments has their packaging systems which make installation simple and aesthetic… So if you work in Java and harmony and beauty are not just senseless terms for you, believe me, you should use Maven.

The main Maven’s advantage over Ant is that each dependency, called artifact can be (and commonly is) an independent project with its own history of versions and dependencies. So, if you want your project to be dependent of any library, you can just find it in one of major Maven repositories, add its id to your pom and – voila! it works.

Then, when time comes to deploy your stuff, you pack it and do the same – upload your stuff to another maven repository. Here the cycle closes and the universal happiness has been achieved.

Now, regarding the subject. There are 2 Maven Eclipse plug-ins in the market – m2eclipse and q4eclipse. Both of them recently were accepted as Eclipse native incubation projects as M2E and IAM. I tried them both starting from the second, but as it always happens, the first was the better one. M2E is very stable, comfortable and easy to understand w/o any documentation, while IAM is pretty buggy and unclear.

So I chose M2E to work with and it took just about 3 hours to convert all my projects to poms, configuring all their dependencies and then converting the projects into Maven managed ones. With the last action, all the Eclipse dependencies convert into Maven dependencies, the build is replaced with Maven build and it guarantees that there will be no surprises in production builds. And then you can proceed with LB/Continuum/CC with no time spent to understand why nothing doesn’t get built correctly.

Now what’s remaining is to reintegrate the changes from the sandbox branch and help the team to not be too scared of the changes 🙂

Written by Seva

2009-02-20 (February 20) at 05:10:21

4 Responses

Subscribe to comments with RSS.

  1. We have a project in which we tried to do exactly what you did: convert to maven, using eclipse. We are no experienced Java developers. I wish we knew what you know, because it has been a nightmare. Every time anyone makes a significant change to a project (e.g. add a new project), everything breaks. We’ve been working getting continuum and the Hudson as our CIS, but that has also never build successfully.

    Any advice?

    Thomas Packer

    2009-05-13 (May 13) at 08:36:41

    • Thomas,

      I understand your concerns. Though managing project dependencies is a manual operation either it is done with Eclipse or with m2eclipse. If you organize your project dependencies correctly the maintenance becomes not much more complex.

      * The most important thing to remember is project dependencies should not be managed manually (the Eclipse way) – use m2eclipse Wizard or edit projects’ pom.xml files instead. Afterward run “Update Project Configuration” to make Eclipse to respect the changes.
      * Do not use m2eclipse wizard when creating a new project. Just create a plain java project, create a simple pom.xml file and then run “Enable Dependency Management”.
      * In general, try to code your pom.xml files as modular as possible, avoid hard-coding constants using dynamic properties instead.


      2009-05-14 (May 14) at 03:03:53

  2. Seva, do you know if M2E has the ability to automatically convert an existing Eclipse project, with existing eclipse based dependencies (jars, other projects) into a Maven/M2E project?

    Rowland Smith

    2009-06-25 (June 25) at 08:10:58

    • Rowland,

      As far as I know, there is no such a possibility yet, and I think there should not be one – full dependencies relation between projects and jar libraries are not exposed in eclipse project configuration (e.g. dependencies between jars and version relations), and it’s more more safe to define them manually, which also will help to better learn Maven dependency mechanism.

      Again, the process should not take much time, even for large projects. I recommend you to refer to the M2E book at


      2009-06-26 (June 26) at 09:15:52

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: