lynaghk / cljx

Write a portable codebase targeting Clojure/ClojureScript
Other
398 stars 34 forks source link

cljx auto generates double output #61

Closed freakinruben closed 9 years ago

freakinruben commented 9 years ago

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"]]
...
  }}
}})
niwinz commented 9 years ago

+1

I'm also experimenting that.

slagyr commented 9 years ago

I'd love a release with this fix included.

danskarda commented 9 years ago

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.

cemerick commented 9 years ago

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.

niwinz commented 9 years ago

Thanks! ;)

slagyr commented 9 years ago

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