Preface

What is Maven? The Maven web site (http://maven.apache.org) states the following:

Maven is a software project management and comprehension tool. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting, and documentation from a central piece of information.

While this captures the idea of Maven, it doesn't really explain what Maven is about. Here's another attempt: Maven provides a rich development infrastructure (compilation, testing, reporting, collaboration, and documentation) from a simple description of any Java project. It is an easy way to build a project without having to build a build system.

Maven started as an attempt to simplify and standardize the complex, Ant-based build process used for Jakarta Turbine. As the build system became more baroque and the Turbine project split into smaller, more focused components, a need emerged for a tool to describe each subproject and manage dependencies. The complexity of this multiproject Ant build created an ideal environment for a new project management system, and Maven 1 is the product of this natural evolution. Maven is frequently compared to the current build tool of choice—Apache Ant. And, while Maven is the clear successor to build systems built around Apache Ant, such a statement tends to cause some controversy... Maven 1 reuses a number of Ant tasks, and when you customize a Maven 1 build, you will end up using the tools that Ant provides. Maven is on a higher conceptual level than Ant; where Ant provides tools such as mkdir and copy, Maven is a build container which provides a common build process—a development infrastructure.

Maven captures best practices and codifies a common build process in a way that can be shared across all projects. When you "mavenize" a project, you create a project descriptor which describes the content and form of a project. This description is then used by common plug-ins which compile, test, package, and deploy project artifacts. In other words, you point Maven at your problem, and it takes care of the solution; you tell Maven where your source code resides, and it takes care of the compilation with little interference from you. You tell Maven to create a WAR file or create a JUnit report, and it retrieves the necessary libraries automatically. Maven is part automation, part build process, and part project description. If you are using Maven properly, you'll find yourself spending less time working on your project's build system and more time working on your project's code.

Just as Maven was inspired by the needs of the Jakarta Turbine project, Jakarta Ant was initially created as a part of the Jakarta Tomcat project. Ant spread like wildfire once people realized it had the potential to simplify project builds. Here's a quote from the Apache Ant FAQ (http://ant.apache.org/faq.html) about the spread of Ant in 1999-2000:

Soon thereafter, several open source Java projects realized that Ant could solve the problems they had with Makefiles. Starting with the projects hosted at Jakarta and the old Java Apache project, Ant spread like a virus and is now the build tool of choice for a lot of projects.

When Ant was introduced, it revolutionized the community; Ant went from a novelty to an indispensable utility in the course of a year. Maven is experiencing a similar transition point as developers start to see how much easier it is to develop with a project management tool.

Note

People used to use Makefiles for Java?! Yes, and it wasn't pretty.

The Future: Maven 2

At the time of this writing, the initial technology preview for Maven 2 is available from the Maven web site (http://maven.apache.org). Although Maven 2 shares lots of concepts with Maven 1, it is a complete rewrite, and builds created for Maven 1 will not be compatible with Maven 2. Maven 1 plug-ins will not be directly compatible with Maven 2 plug-ins, and Jelly has been abandoned as a core scripting language. There will be migration paths, though. This book is peppered with references to Maven 2 and how Maven 2 differs from Maven 1. New features in Maven 2 include:

  • Performance

    Fewer dependencies

    Maven's core drops the dependency on Jelly and Ant.

    Embeddable

    Maven 2 is designed to be embedded in other tools.

    Less Jelly, more Java

    Writing more logic in Java will mean faster execution.

  • Lifecycle mechanism and definition

    Defined lifecycle

    Maven 2 defines a project's lifecycle, and plug-ins hook onto a particular part of that lifecycle. Instead of defining preGoals, postGoals, or prereqs, plug-ins tell Maven where they fit into the defined lifecycle.

    Multiproject aware

    Maven will work with multiple projects by default, and it will be easier to create multiproject builds.

  • Dependency management

    Repository improvements

    Maven 2 will support a new, more-scaleable repository layout (explained in Section 1.1).

    Snapshots

    The mechanism for obtaining SNAPSHOT dependencies will be more configurable. You will be able to configure how often Maven checks for a new snapshot.

    Transitive dependencies

    Maven 2 will allow you to depend on a dependency's dependencies... confusing? If project A depends on artifact B, which in turn depends on artifact C, Maven 2's transitive dependency management will automatically retrieve and include artifact C in project A's dependencies.

  • Customization and plug-ins

    No properties files or maven.xml files

    Behavior is now customized in the POM, which will be stored in pom.xml.

    No Jelly script

    Jelly script will no longer be the core scripting language for goals and plug-ins. For performance reasons, plug-in developers will be encouraged to write plug-ins in Java. Support for scripting languages such as Groovy and Marmalade will be available. A Jelly bridge will be available in Marmalade to easily port existing Maven 1 builds to Maven 2.

Many developers and businesses tend to wait anywhere from a few months to a few years to adopt a new project, and Maven 1 will remain in use for a long time as the feature set of Maven 2 is solidified and Maven 2 has time to prove itself. A final release of Maven 2 should be available in August or September of 2005, and plug-ins will be ported to Maven 2 as developers move to the 2.0 release. Please note that the previous sentence was an estimate; providing a solid date for the release of a software project is an impossible feat, but based on progress at the time of this writing, Maven 2 is well within reach.

Get Maven: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.