Recipe for Tiny Maven Repository

First, I must admit I’m an old fashioned guy that still uses Apache Ant. My reasons may not be easily justifiable and maybe I’m just too lazy to switch but that’s another topic. What I needed to do is to make a Maven repository (for the general public) on a shared hosting account containing jar files that my team creates using Ant.

There are several several applications out there that make maintenance of Maven repository easier. I didn’t try any of those as they looked too heavyweight for my purpose. All I needed was a simple directory structure that Maven repository is. I could not find an appropriate how-to instructions so here it is how I did it…

1. Prepare host for Maven repository

For Maven repository I got a virtual host (I’ll name it here with ftp access.

1.a) Ftp login to your maven host and make directory “/repos”. This will be repository root directory.

1.b) In the root directory of the sate create index.html with some basic information about your repository, eventually linking to the /repos sub-directory.

1.c) I thought it would be useful to instruct search engines not to index repository so I also created robots.txt in the root directory with the following content:

User-agent: *
Disallow: /

1.d) In order to make content of Maven repository browsable, make .htaccess file in the /repos with content:

Options +Indexes

2. Put host ftp credentials to Maven’s settings.xml

Deployment commands reference repository by identifier that has to be defined in Maven’s settings.xml file. Create (or edit) your settings.xml file and specify login credentials for the server. It could look like this:


3. Make pom.xml for your library

Create pom.xml for your library:

<project xmlns="" xmlns:xsi=""
  <name>Library name</name>
    <!-- library dependencies go here -->

You need to provide dependencies section if your library depends on other libraries. If some of third party libraries that you used are not available in any public Maven repository, you may want to deploy them to your repository. Notice also extension element with ftp wagon reference. It’s needed for library deployment using ftp.

Few more comments:

  • There’s a newer beta version of the ftp wagon available but it didn’t work for me in combination with Maven 2.0.9.

  • I tried to use library specific file name (e.g. mylibrary.xml) instead of pom.xml in order to separate my library from POM files related to dependencies. This however failed with some strange error (don’t recall any more) so I ended up creating separate directories and using pom.xml name for all deployed libraries.

  • Deploy library to your Maven host

    mvn deploy:deploy-file -Dfile=sample-library-1.0.jar -DpomFile=pom.xml -Durl= -DrepositoryId=mymavenrepos

That’s it.

Now when I understand how these things work, I could make my life easier automating the process with Ant tasks for Maven. Hopefully soon…