A Guide to Maven 3 Beta
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" -
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" -
- Login or register to post comments
- 30644 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)




Comments
Baruch Sadogursky replied on Wed, 2010/04/28 - 2:09am
Mitchell Pronsc... 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 replied on Wed, 2010/04/28 - 8:55am
in response to: jbaruch
Evan Cowden replied on Wed, 2010/04/28 - 10:22am
matt inger replied on Wed, 2010/04/28 - 4:33pm
in response to: evan38109
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 replied on Thu, 2010/04/29 - 10:35am
in response to: evan38109
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