Creating a Maven Project Local Repository

This is a quick guide on how to add unmanaged dependencies to your Maven project.

By unmanaged dependencies I am referring to those that are not pulled down from Maven Central or an alternative repository defined in a section of the pom.

From time to time you come across that snapshot of a jar, not currently worthy of a maven repository. Perhaps his father didn’t love him enough or perhaps it’s just a son of a git who use to fork around.

You need that jar though, maybe in time it will earn its place in a repo; but you just can’t wait.

It’s at this stage you need to create proper home for the little lost jar, a good home and not just a “lib” folder.

So assuming your project looks along these lines like this:

- src
- target
- pom.xml

You’re going to add another directory called “repo”

- repo
- src
- target
- pom.xml

Then use the maven deploy plugin’s deploy-file goal (execute on one line):

mvn deploy:deploy-file  
-Dfile=fullofmagic -7.7.7-SNAPSHOT.jar

url : the location of the “repo” directory you just created

file : the jar that needs a home, currently resides in the location your are executing maven from.

groupId, artifactId, packaging, version : These should all be fairly familiar to a maven practitioner. If you are not sure what exact values to use, perhaps look at the last release version if one exists.

If you now examine the contents of the repo folder you should see the familiar structure of a maven repository akin to your local .m2 folder. The deployment plugin has created the accompanying meta files.

Ok, so now we need to update our project pom.xml with a new repository entry:


And the dependency:

    <version>7.7.7-SNAPSHOT </version>

Check out the Gist for a full example pom.


Ok so what are the benefits of all this? Basically we have maintained the status quo and the build continues to work for everyone. Individual users don’t have to manually deploy the library from the projects “lib” folder into their own local repo. If you have a CI server you haven’t just scored another manual configuration step either.

Creating a Maven Project Local Repository