For pulling dependencies, Clojure defaults to using Maven and Clojars. There are some cases where you might want to store and serve your own dependencies. It's a security issue if those dependencies change from under your nose (clojars, as of today, allows re-uploading of packages). Also, you might want to isolate yourself from that network dependency (either for performance, uptime, or because you can't access external networks). In addition, you might want to host a stand-alone JAR file that's not on maven anywhere (for example one of your own that's not public). Fortunately hosting on S3 is pretty easy.

Using S3 Wagon Private

You can find a Leiningen plugin here that lets you use S3 as a maven "wagon". This is actually pretty easy to set up, but I had a few gotchas, so I'm just gonna lay out all the steps, duplicating some existing documentation, but paying particular attention to the stuff that tripped me up. Maybe it's because I know nothing about Maven.

First, use the plugin by referencing it in your project.clj, and adding a line that references the location on s3. Here's where I ran into most of my problems with the naming of the s3 bucket and with the options to the repository specification. Without the releases/ suffix, I'd get the following error.

Could not transfer artifact org.keyczar:keyczar:pom:0.71f-readyforzero-build 
  from/to mybucket (s3p://mybucket/): Could not connect to repository
This could be due to a typo in :dependencies or network issues.
Could not resolve dependencies
Without the correct specification of the credentials, I'd get the same final error as above, but would also see the following.
SEVERE: Request Failed.
org.jets3t.service.S3ServiceException: S3 Error Message. GET ..

The only other thing you need to do to make it work is to export the credentials on the shell so that lein can pick them up.

Installing a standalone JAR

Uploading your own JAR to S3 is a little tricky as well, but the upshot is that you need to use maven "deploy-file" instead of "install-file". Just change the file, groupId, version, artifactId to what's appropriate for your JAR. Once you've deployed it locally, just mirror (copy) the entire /tmp/maven-repo dir on s3 under the releases/ dir, and you're good to go.


At ReadyForZero we need use a few standalone JARs and also deploy machines that may not be able to talk out to the open internet for security reasons. Hosting files on S3 let's us manage our dependencies securely. Hopefully this helps someone get over the small issues in doing so.

Discuss this on hacker news.