Maven repository in three steps

So you've crafted something that you'd really like to share with the masses. This post will demonstrate how to create your own Maven2 repository and put your piece of work there. The prerequisite is a domain name that you own ( with a functional HTTP server up and running. Let's assume that you've developed a JAR library with groupId org.dom-ain and artifcatId xxxLib, excerpt from pom.xml:


Step 1:

mvn install -DperformRelease=true -DcreateChecksum=true

This will create all necessary folder structures in your local Maven2 repository (which is located ~/.m2/repository on *nix, and somewhere else on other OSes), and will install all artifacts there (along with md5 and sha1 checksums).

Step 2:

Create a new folder 'maven2' in the HTTP server root so that it would be accessible by URL On HTTP server you MUST enable file listing for maven2 directory and all subfolders (which means 'Options Indexes' for Apache). Then copy the folder branch with the installed library from your local repository there. HTTP server folder structure would look like

[root@httpserv]# ls -R maven2/



0.0.4  maven-metadata-local.xml

xxxLib-0.0.4.jar               xxxLib-0.0.4.pom
xxxLib-0.0.4.jar.md5           xxxLib-0.0.4.pom.md5
xxxLib-0.0.4.jar.sha1          xxxLib-0.0.4.pom.sha1
xxxLib-0.0.4-javadoc.jar       xxxLib-0.0.4-sources.jar
xxxLib-0.0.4-javadoc.jar.md5   xxxLib-0.0.4-sources.jar.md5
xxxLib-0.0.4-javadoc.jar.sha1  xxxLib-0.0.4-sources.jar.sha1

Step 3:

Rename maven2/org/dom-ain/xxxLib/maven-metadata-local.xml to maven-metadata.xml and create checksums for it:

cd maven2/org/dom-ain/xxxLib
mv maven-metadata-local.xml maven-metadata.xml
md5sum maven-metadata.xml > maven-metadata.xml.md5
sha1sum maven-metadata.xml > maven-metadata.xml.sha1

Now everything should work, just make sure that the repository is accessible from the browser. Try to go to this URL: -- the browser is supposed to list all JARs (you library JAR, sources and javadoc) along with their checksums. That's it, now you have your own Maven2 repository that can be referenced from other Maven2 projects. The reference to your repo in pom.xml will look like:


The dependency (a reference) to your library will look like: