A Guide to Maven 3 Beta
A Guide to Maven 3 Beta
Join the DZone community and get the full member experience.Join For Free
Atomist automates your software deliver experience. It's how modern teams deliver modern software.
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 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.
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.
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.
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.
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" -
Opinions expressed by DZone contributors are their own.