2
votes

I am trying to update lein-resource to use clojure.spec which requires the alpha version of Clojure [org.clojure/clojure "1.9.0-alpha13"]. When I add the dependency it compiles ok but the REPL and testing use the lein version of Clojure 1.8.0.

If I set :eval-in-leiningen to false, it respects the Clojure dependency.

How can I test a lein plugin with a different version of Clojure without disabling the ability for it to run as a plugin?

2

2 Answers

0
votes

I'm guessing that your project.clj is getting overridden by your file ~/.lein/profiles.clj. Mine looks like this:

> cat ~/.lein/profiles.clj 
{ :user {   
    :plugins [ 
      [com.jakemccrary/lein-test-refresh "0.16.0"]
      [jonase/eastwood  "0.2.3"] 
      [lein-ancient     "0.6.0"]
      [lein-codox       "0.9.3"] 
      [lein-exec        "0.3.6"] 
    ] 
    :dependencies [ 
      [org.clojure/clojure "1.9.0-alpha13"]
    ]
    :test-refresh { :quiet true
                    :changes-only true }
  ; :jvm-opts ["-Xms1g" "-Xmx4g" ] ;   "-server"
  }
}

I'm assuming your project.clj should look something like this:

(defproject clj "0.1.0-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.9.0-alpha13"]
    [tupelo "0.9.9"]
  ]
  :java-source-paths ["/home/alan/xpr/src"]
  :main ^:skip-aot clj.core
  :target-path "target/%s"
  :profiles {:dev      {:dependencies [[org.clojure/test.check "0.9.0"]] }
             :uberjar  {:aot :all}}
)

Fix up your ~/.lein/profiles.clj and you should have no problem.

0
votes

Turns out the problem is :eval-in-leiningen true in the project.clj. It is a bit of a catch-22. If it is there, it forces the test to run with the version of Clojure defined with the installed with lein. If it is removed, the lein dependecies in the code are not resolved.