Clojure project with a corporate maven repository
Clojure is great and it has ton of features that allow developers to increase productivity. With this post we intend to show how to configure clojure to use a repository manager as proxy and how to setup the clojure project to deploy JAR files for shared usage.
Preparation (repository manager setup)
For this tutorial we are going to assume that the Nexus OSS 3 corporate repository manager is configured similar to this:
- Anonymous browsing disabled.
The Clojars.org repository configured as a repository proxy.
Add the Clojars repository to the maven public group repository.
Add any extra maven repository that is needed in the same way.
Local setup ~/.lein/profiles.clj
{:user
{:mirrors {#".+" {:url "https://my.local.repo/repository/maven-public/"
:username :env :password :env }}}}
The line
{:mirrors {#".+" {:url "https://my.local.repo/repository/maven-public/"
tells leiningen to send any request to a repository that matches".+"
to the maven public group repository.The line
:username :env :password :env
makes leingigen use the environment variablesLEIN_USERNAME
andLEIN_PASSWORD
as authentication credentials.
Project setup lib-tools/project.clj
- Lastly, add the section
deploy-repositories
to yourproject.clj
and in order to deploy to the maven repository runlein deploy
(defproject net.spantree/lib-tools "0.0.1-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.145"]
[cljs-http "0.1.30" :exclusions
[org.clojure/clojure
org.clojure/clojurescript]]]
:deploy-repositories [["releases" {:url "https://my.local.repo/repository/maven-releases/"
:username :env :password :env }]
["snapshots" {:url "https://my.local.repo/repository/maven-snapshots/"
:username :env :password :env}]])
- The output of the command should look similar to this:
$ lein deploy
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
WARNING: please set :description in project.clj.
WARNING: please set :url in project.clj.
Created /Users/otaeguis/projects/src/lib-tools/target/lib-tools-0.0.1-SNAPSHOT.jar
Wrote /Users/otaeguis/projects/src/lib-tools/pom.xml
Retrieving net.spantree/lib-tools/0.0.1-SNAPSHOT/maven-metadata.xml
from https://my.local.repo/repository/maven-snapshots/
Sending net.spantree/lib-tools/0.0.1-SNAPSHOT/lib-tools-0.0.1-20160713.062217-13.jar (9k)
to https://my.local.repo/repository/maven-snapshots/
Sending net.spantree/lib-tools/0.0.1-SNAPSHOT/lib-tools-0.0.1-20160713.062217-13.pom (3k)
to https://my.local.repo/repository/maven-snapshots/
Retrieving net.spantree/lib-tools/maven-metadata.xml
from https://my.local.repo/repository/maven-snapshots/
Sending net.spantree/lib-tools/0.0.1-SNAPSHOT/maven-metadata.xml (1k)
to https://my.local.repo/repository/maven-snapshots/
Sending net.spantree/lib-tools/maven-metadata.xml (1k)
to https://my.local.repo/repository/maven-snapshots/

Sebastian Otaegui
Sebastian Otaegui is a system admin currently living in Buenos Aires. He started his career working as one of the web hosting administrators in the eBusiness hosting team at IBM, soon he got tired of the red tape that big organizations suffer. After working for one year for a very large extended warranty company, he was asked to move to Chicago to work as the team leader for the web hosting administration team. During the six years working at The Warranty Group he met Cedric. Sebastian and Cedric became friends and begun introducing concepts that back then didn't have a name and today are known as DevOps practices.
In his free time, Sebastian enjoys trying new technologies, watching movies with his wife and playing Star Wars The Old Republic. Fun fact about Sebastian is he played rugby for 14 years.