You can use Leiningen profiles or classifiers for what you are talking about.
Profiles
(defproject im.chit/sigmund "0.2.0"
:description "System analytics for Clojure"
:dependencies [[org.clojure/clojure "1.5.1"]]
:profiles {:dev {:dependencies [[midje "1.5.0"]]}
:jre6 {:jar-name "sigmund-jre6.jar"
:dependencies [[sigar/sigar "1.7.0-v20131027"]
[sigar/sigar-native-deps "1.7.0-v20131027"]]}
:jre7 {:jar-name "sigmund-jre7.jar"
:dependencies [[sigar/sigar "1.7.0-v20131027"]
[sigar/sigar-native-deps "1.7.0-v20131027"]]}})
Node: The jre6
and jre7
profile names are arbitrary, and do not do anything beyond a standard lein profile. I just used meaningful names so their use would be obvious.
And, you can run tasks with both the jre6
and dev
profiles combined by separating them with a comma, on the command line.
$ lein with-profiles jre6,dev test
If you want to jar them with a single command, you would separate them with a colon.
$ lein with-profiles jre6:jre7 jar
Classifiers
(defproject im.chit/sigmund "0.2.0"
:description "System analytics for Clojure"
:dependencies [[org.clojure/clojure "1.5.1"]
[sigar/sigar "1.7.0-v20131027"]
[sigar/sigar-native-deps "1.7.0-v20131027"]]
:classifiers [["jre6" :jre6]]
:profiles {:dev {:dependencies [[midje "1.5.0"]]}
:jre6 {}})
In this case, the default profile would correspond to the current version, supporting JRE 7, and the :jre6
profile would be for the previous version.
$ lein jar
Created /Users/user1/sigmund/target/sigmund-0.2.0.jar
Created /Users/user1/sigmund/target/jre6/sigmund-0.2.0-jre6.jar
You would reference the "jre6" jar with the :classifier
keyword in your :dependencies
vector.
(defproject tester1 "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.5.1"]
[sigmund "0.2.0" :classifier "jre6"]])
This method is limited because, due to the way the pom file is generated, you cannot specify different dependencies for each classified jar. Other settings affecting jaring, such as source directories and AOT, should work.