Adding Custom Libraries Into Local Leiningen Repository

Sometimes, your project depends on a library which is not in clojars, or maybe it is propriety library which you can't upload to clojars. In this case, you can put it to your local repository your self to solve the dependency.

mvn install:install-file \
    -Dfile=mysql-connector-java-5.1.10-bin.jar \
    -DgroupId=self \
    -DartifactId=mysql-connector \
    -Dversion=5.1.10 \
    -Dpackaging=jar \
    -DgeneratePom=true

This will add the mysql adapter into your local Maven2 repository under groupId self and artifactId mysql-connector, you can then edit your project.clj, adding this dependency as,

[self/mysql-connector "5.1.10"]

Alternatively you can keep your jars with your project, create folder to hold the jars,

mkdir local_mvn_repo

add the jars to this repository,

mvn install:install-file \
    -Dfile=mysql-connector-java-5.1.10-bin.jar \
    -DgroupId=self \
    -DartifactId=mysql-connector \
    -Dversion=5.1.10 \
    -Dpackaging=jar \
    -DgeneratePom=true \
    -DcreateChecksum=true\
    -DlocalRepositoryPath=local_mvn_repo

and add this local maven repository to your project.clj

:repositories {"local" ~(str (.toURI (java.io.File. "local_mvn_repo")))}