Mitch Pronschinske is the Lead Research Analyst at DZone. Researching and compiling content for DZone's research guides is his primary job. He likes to make his own ringtones, watches cartoons/anime, enjoys card and board games, and plays the accordion. Mitch is a DZone Zone Leader and has posted 2578 posts at DZone. You can read more from them at their website. View Full User Profile

A Guide to Maven 3 Beta

04.27.2010
| 36879 views |
  • submit to reddit
In just over six years, Apache Maven has become one of the most coveted tools for project build and reporting management.  It's been five years since the release of Maven 2 and now the Maven committers have released the next landmark version of the software.  The first beta release of Maven 3, which is now feature complete after 7 public alphas, was released this week.  Maven founder and Sonatype CTO Jason van Zyl answered some questions for DZone about Maven 3 earlier this month.  Below are the main new feature categories of Maven 3.

Drop-in Replacement
Users of Maven 1.x may remember the bumpy transition to Maven 2 because of several fundamental changes.  The Maven committers remember too, and they've put a lot of extra work into providing backward compatibility and making Maven 3 a simple drop-in replacement for Maven 2.x in most cases.  van Zyl says this was "very difficult given how much of the internals we've changed."  Apart from fixing problems with duplicate dependency and plugin declarations, no changes are needed for your POMs.  They've made the command-line fully compatible between 2 and 3.

Polyglot Maven
Polyglot Maven is not a part of Maven 3 per se, but it is a tool from van Zyl's company, Sonatype, that can be integrated with Maven 3 via an extension point.  The extension points are a new feature in Maven 3 that support tools such as Tycho, Polyglot Maven, and Maven Shell.  As you've probably guessed from the name, Polyglot Maven supports dynamic languages and is trying to provide first-class POM-mapped DSL (Domain Specific Language) support for Groovy, Scala, Clojure, Ruby, Xtext, and YAML.  Polyglot Maven currently supports YAML.  This is a welcome feature for developers who find the original XML format to be annoying.  If you don't, no big deal.  van Zyl also says its important for these DSLs to have repository interoperability and tooling so they can leverage M2Eclipse.

M2Eclipse
Maven 3 has changes related to embedding that make it work a lot better inside of M2Eclipse (the first Maven integration plugin for Eclipse).  Maven 3 is now capable of a 200 to 300% performance boost while running in this plugin environment built specifically for Maven and the Eclipse IDE.  M2Eclipse will provide some extra XML metadata in the Maven POM, and it is only recognized by M2Eclipse.  This is one feature that enables the high build performance.  M2Eclipse also downloads all sources automatically and has a single-click new project creation feature for any of your dependencies.

Maven Shell
The Maven Shell is another extension point.  It is Maven embedded in a long-lived shell process that caches parsed POMs, avoids start-up costs when invoking Maven repeatedly, supports Maven Archetype integration, provides Nexus integration, includes a built-in help system, and on Mac OS X it provides Growl support.  van Zyl says typical cases will see a 50% reduction in build times. Version 1.0 of the Maven Shell integrates the make-like reactor mode that builds only the modified modules.   Support for project workflow, Hudson, Tycho, and Polyglot Maven are also present.

Other improvments
Developers working in multi-module or multi-pom projects won't have to specify the parent version in every sub-module in Maven 3.  Instead, you can add version-less parent elements.  Maven 3 will also be able to see which POMs supplied which artifacts.  In M2Eclipse, you will then be able to de-select a certain contribution and select others.  This is made possible through Maven 3's decoupling of execution plans and execution.  Maven 3 also includes extention points (mentioned above), which allow developers to hook up to different extension points, instead of sub-classing a plugin, to alter the plugin behavior.  You might, for example, have an extension point to alter the way web.xml is processed through the WAR plugin.  

The source code in Maven 3 uses Google Guice for dependency injection and Peaberry to add OSGi capabilities to Guice.  The whole dependency resolution is refactored into a standalone product by Sonatype called Mercury, for which Maven 3 is a client.  Believe it or not, the Maven 3 codebase ended up being 1/3rd smaller than Maven 2.

Maven 3.1
Looking towards the next release, Maven 3.1 will include a security manager with the settings.xml implementation as the default.  Sonatype is planning an implementation that interacts with Nexus.  Maven 3.1 will also introduce POM mixins, which make configuration more maintainable and portable.  Mixins will help solve the problem in Maven 2.0 where sharing configuration could only be done via inheritance.  POM mixins are a type of POM composition that allows parameterized POM fragments to be injected into the current POM with a simple reference.

References:  "What's New in Maven 3" -

Comments

Baruch Sadogursky replied on Wed, 2010/04/28 - 2:09am

Is there any documentation available on embedding Maven3, except of sources of M2Eclipse?

Mitch Pronschinske replied on Wed, 2010/04/28 - 6:54am

It looks like most of the inaccuracies came from the information here.  It's a summary of a previous presentation on Maven 3.

The last point's inaccuracy comes from some confusion about this statement in Jason van Zyl's Eclipse Magazine interview:

"Internally in Maven 3.1 we will expose a security manager and use the settings.xml implementation as the default implementation, but Sonatype is planning on creating an implementation that interacts with Nexus, our repository manager. In dealing with many large organizations we have found that integrating with in-house security systems and custom implementations is necessary so we will be providing an extension point for this with the security manager."

Jason Van Zyl replied on Wed, 2010/04/28 - 8:55am in response to: Baruch Sadogursky

We will have embedding examples in Hudson and Nexus in the next month, but the official documentation won't be published until the embedding APIs are final which will most likely be when Maven 3.0 is final.

Evan Cowden replied on Wed, 2010/04/28 - 10:22am

Is there a website somewhere for Maven3? There's the beta download on the Apache Maven website, some projects mention it in passing - like M2Eclipse or those at Sonatype - and a collection of blogs spread across the web, but I can't find any central or official source of info.

matt inger replied on Wed, 2010/04/28 - 4:33pm in response to: Evan Cowden

Beta download:

http://maven.apache.org/docs/3.0-beta-1/release-notes.html

 

I can't find any actual maven 3 documentation on the website though.

Jason Van Zyl replied on Thu, 2010/04/29 - 10:35am in response to: Evan Cowden

To the casual users from the CLI perspective, Maven 3.0 is intended to be a drop-in replacement. Many of the internals have changed, and so for integrators there are many changes and those will be documented closer to the 3.0 release. There will be fully working examples of integration in Nexus, Hudson, M2Eclipse, and Tycho as well.

Avinash Gupta replied on Fri, 2010/04/30 - 2:57am

What is the plan on final release of Maven 3? Is it coming soon? Or will there be several beta cycles (just like 7 alpha cycles) before we get the final release?

I am confused if Maven 3.1 will come before final Maven 3.0 release.

William Houghtaling replied on Mon, 2011/07/04 - 8:03am

The Maven 3 Beta still lock something and what i have read in the link that was given it has some nice upgrade on it and it is very nice to read and to know. Hopefully the Maven 3 will be what we expect it to be. Some of the issues that will be incountering in this beta hopefully will be fixed in the Maven 3.  Gauthier, Houghtaling and Williams

Carla Brian replied on Fri, 2012/06/22 - 8:27pm

A major aim of the refactoring in Maven 3.x was to decouple the Maven core from Doxia and to allow arbitrary reporting systems to be developed.  - CWD Construction

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.