Apache Maven 1.x has reached its end of life, and is no longer supported. For more information, see the announcement. Users are encouraged to migrate to the current version of Apache Maven.


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.

Building from SVN: 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!

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/trunks maven-1

Note: the maven-plugins tree is required for the the bootstrap process. If you have downloaded a released source distribution of Maven (which doesn't include the plugins), you either have to checkout the plugins separately, or use Maven itself to build itself!

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 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-1/core tree available, either checked out from SVN, or from one of the released source distributions. Unlike the bootstrap, the maven-1/plugins 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-1/core 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 core 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:distribution 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), as well as a source tar ball. The generated binaries can then 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-1/plugins checked out from Subversion at the same level as the maven-1/core 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.

plugins:install-all 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.
plugins:test-all Test each Maven plugin. This runs any integration tests available for individual plugins.
plugins:repository-deploy-all Deploy all plugins in a remote repository.
plugins:site Create the web site root for all plugins.
plugins:build-all-sites Create the web site for all plugins and for the root site.
plugins:deploy-all-sites Deploy the web site for all plugins and for the root site.
plugins:publish-all-sites Publish the web site for all plugins and for the root site.


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.

MAVEN_OPTS=-XX:MaxPermSize=128m -Xmx512m