Maven and M2Eclipse

As many already know M2Eclipse is the official Apache Maven integration for Eclipse. We have been working on M2Eclipse for over 10 years now: we made our first commit in December, 2005 at Codehaus and brought M2Eclipse to the Eclipse Foundation with Igor Fedorenko as the lead in November, 2010. Since then we've had six major releases and have been a standard part of the Eclipse release train since Indigo in 2011.

Historically, trying to integrate Maven with Eclipse has been quite a challenge. We have Eclipse being an OSGi-based system, having its own internal builders, having its own classloader/classpath management, and using JDT for compilation with its own way of tracking incremental build state. Over time we have made adjustments on the Maven side, patched and collaborated with existing tools, have created new APIs to try and bridge the gap and for the most part I think we've succeeded.

A critical integration path is how existing Maven plugins work inside M2Eclipse. This is actually more challenging than integrating Maven itself because there are literally thousands of Maven plugins that work in all sorts of weird and wonderful ways. Not all Maven plugins are created equal, and many of them do not play very well inside an embedded, incremental environment like Eclipse. We have tried to make Maven plugin integration easier in M2Eclipse by creating the Configurator API and the Takari Incremental API.

The Configurator API is a general mechanism for configuring Eclipse projects in the workspace from configuration that is present in a Maven POM. A simple example of how this works is the way in which we set the source/target compiler options for JDT in Eclipse from the configuration in the maven-compiler-plugin . Any M2Eclipse extension, or what we call connectors, can use this API to manipulate the state of the Eclipse project and we have connectors for many tools like Antlr, JavaCC, PMD, and Checkstyle.

The Takari Incremental API is an attempt to alleviate the burden of having to write a connector for many classes of Maven plugins. If you are generating content like sources, resources from annotations, JARs, or anything similar to what happens in the default Maven lifecycle and you use the Takari Incremental API then you don't have to write a connector to integrate with M2Eclipse. If you adhere to the Takari Incremental API you can use the Takari TEAM Connector and the integration with M2Eclipse will be handled for you. For an example of how the Takari Incremental API is used, you can take a look at the Takari Lifecycle Plugin. We hope that over time developers will use the Takari Incremental API for their Maven plugins which will provide better performance and the best integration with M2Eclipse.

We are also very proud of our development support for Maven core, Maven plugins, and Maven extensions. We have been working on this support for nearly 8 years and it's no trivial effort. We can easily run/debug through the entire graph of M2Eclipse dependencies from within the Eclipse workspace. We can develop Maven plugins or Maven extensions from within the workspace running with the version of Maven in the workspace. It means that we never have to install anything in the local Maven repository in order to work on new features of Maven, new plugins or extensions. It all just works inside M2Eclipse with no need for remote debugging. If you develop Maven plugins then I highly recommend you take a look at the video we put together demonstrating these development capabilities. It really is a huge time saver and alleviates most of the frustration while trying to develop for Maven.


Along the way we've gained some really great core contributors. Working on M2Eclipse is not easy as you have to understand how Eclipse works and how Maven works. Two fairly sizable ecosystems in their own right, and getting them to work together is not always straight forward. Fred Bricon has been with us for many years, is the lead of the m2e-wtp component, and works on integrating M2Eclipse and WTP into JBoss Tools for Red Hat. Fred has made some great usability improvements like radically speeding up project imports, and automatically keeping project configurations up-to-date so that users don't have to manually. Anton Tanasenko joined us last year and has made numerous improvements including revamping the Maven plugin configuration content assist in the POM editor.

We also have some exciting changes happening in Maven and some of those changes have made their way into some experiments on the M2Eclipse side. Recently Takari released Polyglot for Maven with DSLs for Ruby, Groovy, Scala, Clojure and POM markups for YAML and Atom. Fred Bricon is excited about Polyglot for Maven and created a prototype for integrating it with M2Eclipse. The JRuby team also recently switched over to using Polyglot for Maven with the Ruby DSL! You can check that out on JRuby master at Github.

We are also excited about the new Eclipse Andmore which integrates the M2Eclise Android connector and the Android Maven Plugin. Dave Carver, Ricardo Gladwell, and Manfred Moser are really doing admirable work on their respective projects and we're starting to see it all come together in the Andmore project which is great to see.

If you ever have any questions, or want to know more about the M2Eclipse project please visit the community page on our website!

About the Authors

jasonvanzyl

Jason van Zyl
Takari, Inc.

About the Author
jasonvanzyl

Jason van Zyl
Takari, Inc.