How to install your project into Maven local repository example

In this tutorial, we will show you an easy way to install your project into your Maven’s local repository, using Apache Maven. Maven is able to build, package and deploy a project to our local repository.

First of all, we must understand how Maven builds and deploys a project. Each Maven project undergoes a specific build lifecycle. The default lifecycle has the following build phases:

1. validate5. integration-test
2. compile6. verify
3. test7. install
4. package8. deploy

For more information, please refer to the official Maven introduction to the build lifecycle.

In order to install our Maven project, we must first navigate to its folder, using the terminal (Linux or Mac) or the command prompt (Windows). Then, we must issue the following command:

mvn install

This command is responsible for executing Maven’s install phase. Maven executes each build phase sequentially thus, before the install phase, Maven will execute all previous phases.

1. Sample Execution

Inside the pom.xml file, we can:

  • Define our packaging type, such as jar or war.
  • Define the name of our file.
  • Define the version of our file.

By using the following pom.xml file


<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">



we create a new file called SampleExample-1.0.0.jar inside our local repository:


Finally, it is a good practice to use Maven’s install command along with Maven’s clean command as following:

mvn clean install

This command first, cleans our project by removing everything inside the target folder and then, installs our executable file inside Maven’s local repository.

2. Use our Project as a Dependency

After we have successfully installed our project into Maven’s local repository, we can use it as a dependency to another project, by adding to our pom.xml file, the following code snippet:


This was a tutorial on how to install a project, using Apache Maven.

Sotirios-Efstathios Maneas

Sotirios-Efstathios (Stathis) Maneas is a PhD student at the Department of Computer Science at the University of Toronto. His main interests include distributed systems, storage systems, file systems, and operating systems.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button