lynaghk / cljx

Write a portable codebase targeting Clojure/ClojureScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cljx auto generates double output

freakinruben opened this issue · comments

I'm using cljx 0.5.0 and it works great when I run lein cljx once. However, when I run lein cljx auto it will generate the code twice and I'm not sure wether this is caused by a misconfiguration in the project.clj or a bug of cljx.

The following folders are created:

  1. target/generated-src/{ns}... -> correct clj/cljs files
  2. target/generated-src/file//{path-to-project}/test/cljx/{ns}/... -> contains generated clj/cljs test-files
  3. target/generated-test/{ns}... -> correct clj/cljs test-files
  4. target/generated-src/file//{path-to-project}/src/cljx/{ns}/... -> contains generated clj/cljs files

With lein cljx once only the folders of 1 and 3 are generated.

My project.clj contains the following:

(defproject ...
  :source-paths ["src/clj" "src/cljs" "target/generated-src"]
  :test-paths ["test/clj" "test/cljs" "target/generated-test"]
...
  :auto-clean false
  :cljx {:builds [{:source-paths ["src/cljx"]
                   :output-path "target/generated-src"
                   :rules :clj}
                  {:source-paths ["src/cljx"]
                   :output-path "target/generated-src"
                   :rules :cljs}
                  {:source-paths ["test/cljx"]
                   :output-path "target/generated-test"
                   :rules :clj}
                  {:source-paths ["test/cljx"]
                   :output-path "target/generated-test"
                   :rules :cljs}]}
...
  :dependencies [
    [org.clojure/clojure            "1.6.0"]
    [org.clojure/clojurescript      "0.0-2511" :scope "provided"]
...
  ]
  :profiles {
    :dev {
      :plugins [[com.keminglabs/cljx  "0.5.0"          :exclusions [org.clojure/clojure org.clojure/clojurescript]]]
      :prep-tasks   [["cljx" "once"]]
...
  }}
}})

+1

I'm also experimenting that.

I'd love a release with this fix included.

Hi @cemerick,
please could you make new release with this fix?

This bug is particularly ugly with emezeske/lein-cljsbuild#362. Cljx creates additional .clj files (which include file: inside its path), cljsbuild tries to load them and fails.

Thank you.

I really appreciate @niwibe's work in addressing this, but the proposed PR was just too complicated (adding a suite of general-purpose string processing fns, etc).

I believe I've addressed this on master. Available in [org.clojars.cemerick/cljx "0.6.0-SNAPSHOT"] until the final 0.6.0 release is cut. Please test that and report any remaining problems.

Thanks! ;)

Brilliant! Thanks Chas! This solves the problem and I'm now able to use cljx and cljsbuild in conjunction.