2
votes

I'm working on a library that works with both Clojure and ClojureScript.

Here's the project.clj for the library:

(defproject libtest "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.4.0"]]
  :plugins [[lein-cljsbuild "0.3.0"]]
  :cljsbuild
    {:crossovers [libtest],
     :crossover-jar true
     :jar true
    :builds
    [{:source-paths ["src/libtest"], :crossover-path "src/libtest"}]})

I'm including it as a dependency in another project. To get it to work from the ClojureScript side of my project, I had to add the exact namespace as a crossover under the cljsbuild key of my project.clj:

 (defproject some-other-project
    ...
    :dependencies [[org.clojure/clojure "1.5.0"]
                   [libtest "0.1.0-SNAPSHOT"]]
    :cljsbuild {
        :builds [{
    ...
            :crossovers [libtest.core]
    ...

My question is, is this necessary? If it's on the classpath, why must I specifically tell it what namespaces I'm going to use? This can't scale well if I need to use dozens of namespaces, some of which will reference other namespaces and etc.

1

1 Answers

0
votes

This is not a perfect solution, but works for me. When a namespace is specified as a crossover, its children are added recursively. So :crossovers [libtest] will add libtest.core too. If you specify a :crossover-path, you can see what files are generated into that directory.