Building Maven is a little different than your typical Java build because Maven uses itself to build itself! So, in order to successfully build Maven from scratch, a bootstrapping process is required to jumpstart the build. Alternatively, if you already have Maven installed and would just like to build a newer version, you can follow these instructions.

Bootstrapping Maven with Ant

Before you can build Maven, you'll need to make sure you have Ant 1.5 or higher installed on your system.

You also must have the MAVEN_HOME environment variable set. The Maven installation is encapsulated in the directory specified by MAVEN_HOME: scripts, Maven's run-time library, plug-ins and the local repository. MAVEN_HOME must not end with a path delimiter - ie. / or \

Note: if you already have Maven installed, MAVEN_HOME is probably already set. Unless you really want to delete that installation completely and install the new build there, make sure you change it before bootstrapping!

For the impatient reader that doesn't want to read the rest of this document, type the following:

ant -f build-bootstrap.xml

If you are new to Maven, it is recommended that you read the rest of the document as it explains the build process in a little more detail.

Before you can begin the process, you'll need to download the source from the maven and maven-plugins Subversion repositories. For example, using the command line:

svn co http://svn.apache.org/repos/asf/maven/maven-1/core/trunk maven-1/core/trunk
svn co http://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk maven-1/plugins/trunk

After setting the value of MAVEN_HOME and pulling down the sources you are now ready to build and install Maven on your system using the bootstrapping process. As mentioned earlier, the bootstrapping process is defined in build-bootstrap.xml, and can be initiated by typing the following from the maven-1/core/trunk directory:

ant -f build-bootstrap.xml

After initially constructing a basic Maven install with Ant, the bootstrap will use Maven to rebuild itself.

If you had any problems during building, refer to the troubleshooting section below.

Thats it! Congratulations! You have now built Maven with Maven and installed Maven on your system!

Building Maven with Maven

This section explains how to build Maven with Maven already installed. This assumes that you have the maven CVS tree checked out. Unlike the bootstrap, the maven-plugins CVS tree is not required as the following goals will download (if necessary) the latest plugin releases and use those instead of building them from sources. If you wish to do this, please read Building Plugins From Sources.

Start by running maven -u in the maven CVS tree's base directory. This will give you a quick overview of the defined goals.

Building a Complete Maven Installation

If you are building a different version of Maven to the one currently installed, or the one installed is your "clean" installation, you can build a complete Maven installation with the following goals invoked from the maven maven CVS tree.

maven:build-install This builds a complete install in the target/installer/maven-X.Y.Z directory. Note that you must copy this to your desired location yourself as it cannot delete and overwrite MAVEN_HOME as that is the location of the currently running version of Maven.
maven:installer This builds a complete install in the target/installer/maven-X.Y.Z directory, as above, and then generates a .tar.gz, .tar.bz2, .zip, and .exe (if on Windows with NSIS installed). These can be used like the distributed binaries to install Maven elsewhere. Note that you must install this to your desired location yourself as it cannot delete and overwrite MAVEN_HOME as that is the location of the currently running version of Maven.

Working on a Development Version of Maven

If you are developing a patch for Maven itself, you need a development installation of Maven that you can use and change. This should be set up using the instructions above using Maven, or by bootstrapping.

Note that when doing this, if you happen to make a valid Maven JAR that has a bug, you may render your current Maven installation unable to rebuild itself. You should keep a clean copy to use in this case, otherwise you will have to rebuild it from scratch as specified above, or by bootstrapping.

maven:jar-install This builds maven.jar from the sources, runs all of the unit tests, and installs it into the same directory as the running version of Maven (MAVEN_HOME/lib).
maven:run-touchstone This will run the touchstone tests on the currently version of Maven. This should be run after maven:jar-install when you are happy with your code. The touchstone tests are actually a set of integration tests that sanity check various features, and quirks expected by users of Maven for backwards compatibility.

Building Plugins From Sources

To build the plugins from sources, you need to have maven-plugins checked out from CVS at the same level as the maven CVS tree (not underneath it).

These goals have some common logic: they invoke the reactor on the plugins directory and use the properties maven.plugins.include and maven.plugins.exclude to determine which to build and/or install. You can customise these variables by copying the values from project.properties into build.properties in the same directory and changing them.

It is also possible to use the multiproject goals to do this from the maven-plugins directory. For more information, refer to the Maven Plugins project documentation.

maven:plugins-install Clean, build and install each Maven plugin into the running Maven installation (though they will not be utilised until next execution). This is the most commonly used goal.
maven:plugins-testTest each Maven plugin. This runs any integration tests available for individual plugins.
maven:plugins-clean Cleans all plugin projects.
maven:plugins-build Build each Maven plugin into an installable jar. The plugins are not actually installed, so this is useful simply to see if they all build.


If you are behind a proxy, you must define proxy parameters for building Maven. See this FAQ for details.

If you get an OutofMemoryError during bootstrap, try setting an environment variable MAVEN_OPTS to provide more memory, e.g.