Creating Your Own Remote Maven Repository

By default, when you install Maven, it is configured to use http://www.ibiblio.org/maven as the remote repository; ibiblio provides a comprehensive selection of free and open source artifacts. This repository is appropriate if you're developing a free and open source product, but what if your project needs to depend on either commercial artifacts or artifacts internal to your company? For example, if you need to depend on a commercial JDBC driver, you will need to set up your own remote Maven repository.

How do I do that?

This is really simple: all you need is a web server. You can use any web server you like, be it Apache, Tomcat, Microsoft IIS, etc. The only recommendation is that it supports the if-modified-since HTTP header (but we think they all do!), as this is the internal mechanism used by Maven to decide whether an artifact needs to be downloaded to your local repository.

Let's use Tomcat. Download it from http://jakarta.apache.org/site/downloads/downloads_tomcat.html (at the time of this writing the latest version available in the 4.x series was Tomcat 4.1.31). Install it anywhere you wish—say, in C:\apps\jakarta-tomcat-4.1.31 if you're on Windows—and start it using bin/startup.bat (for Windows) or bin/startup.sh (for Unix). By default, Tomcat will start on port 8080. If you're already using this port, edit the config/server.xml file and modify the port. Verify that you have it working by opening a browser and typing http://localhost:8080 ...

Get Maven: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.