I have a project.clj
file that I want to use differently depending on an argument passed in when called by leiningen. Here is my hypothetical sample project
(defproject simple "0.0.1"
:source-paths [(get-argument "source.path")])
(In this case get-argument
would simply call System/getProperty
). I would use this file like this,
lein2 compile -Dsource.path=path/to/location
The problem is two-fold,
- I don't know how to pass an argument to leiningen. It doesn't accept the
-Dkey=value
syntax. I couldn't find anything in documentation about passing optional/extra arguments. Am I missing something obvious? - The subforms inside
defproject
seem to be handled a special way. I couldn't find an easy way to put code into it.
I have found some approaches
- https://github.com/weavejester/environ looks promising, but it seems to work only in proper clojure code, not inside project.clj
- https://groups.google.com/forum/?fromgroups=#!topic/leiningen/t8G6Et1_j8w -- this is a workaround that may solve half of the problem
- What is an elegant way to set up a leiningen project that requires different dependencies based on the build platform? gives some idea how to eval code in project.clj
- https://github.com/sattvik/leinjacker promises to do some dirty tricks, but I couldn't make it work in my environment
(What I actually want to use it for is that I have a clojurescript project with different artifacts. While it's possible to configure different builds for it, they all share the same crossovers.)