Setting up your own Maven repository

I’ve just setup a local Maven repository so that I can share libraries I develop with other developers on campus. It was really easy, all you need is a filesystem that you can SCP to, you don’t need to install anything on it. Here’s how:

1. In the POM of the project you want to put in a repo:

    <name>Enterprise Systems Maven Repository</name>    

You can also separate snapshot releases from point releases in two different repositories, by defining a snapshotRepository element as well as the repository element, same attributes as above.

2. Setup your username and password that will be writing to the repo:

2a. If you have not yet set a master password for Maven, you need to create one. If you have done this already, skip to 2c.

mvn --encrypt-master-password masterpasswordhere


2b. Create a file .m2/settings-security.xml with that password:


2c. Encrypt your password you are going to use for pushing to this repository:

mvn --encrypt-password hello


2d. In .m2/settings.xml add a server block with that password, and matching id for the repo:

<servers>  ....  
  </server>  ....

3. Build and deploy your project to the repo:

mvn clean install source:jar javadoc:jar deploy

After it builds you should see it uploading the artifacts.

4. Now, in the POM of another project, you can set up your new maven repo as a repository to search and pull artifacts from:


One thought on “Setting up your own Maven repository

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s