Hi Karsten,

Strangely, I was doing the exact same thing as you yesterday and
struggled for a bit until I found settings that work.

I achieved success when I used the configuration from Cornice as a template:

https://github.com/rkneufeld/cornice/blob/master/project.clj

...with one exception, my cljsbuild config contained only

:cljsbuild {:builds [{:source-paths ["target/generated/cljs"]}]}

vs. all the extra jar config and one not.  If I recall correctly, I was
getting the "java.util.zip.ZipException: duplicate entry" you mention
until I removed the extra settings in cljsbuild.

Looking at your config I also suspect you want

> :source-paths ["src-cljs"]

instead of

> :source-paths ["src-clj" "src-cljs"]

in your cljsbuild config.

However, when I leave the cljsbuild configuration out completely, it
seems to have no bearing on whether or not I can use the generated cljs
files when including the library in another project.  I suspect the
":jar true" setting is only relevant if you have strictly cljs files
that need to be included--it seems like cljx has its own orthogonal
build process which automatically includes cljs files in the jar file
but I haven't dug into the code yet to confirm.  This is just based on
testing what happens when I tweak config settings (Kevin or Chas please
let me know if I'm off-base here).

What does seem to make all the difference is the sourcepaths settings,
which it doesn't seem you have:

:source-paths ["src" "target/generated-src/clj" "target/generated-src/cljs"]

I needed this before I could see the clj/cljs files getting included in
my library jar.

Obviously, adjust all paths to fit your specific configuration.

I've made a pull request to add a bit of further explanation on using
cljx in libraries, as it would be helpful if this didn't require looking
up how others had done it to figure it out!

https://github.com/lynaghk/cljx/pull/30

Hope this helps--

Best,
Dave

(2014/02/13 20:22), Karsten Schmidt wrote:
> I've been busy working on a few libraries targetting both Clojure &
> ClojureScript, however so far have only tested the CLJ side and now that
> it comes to addressing CLJS am running in circles (and on fumes)
> unsuccessfully trying to tweak my project settings to make things work.
> 
> All my source is using CLJX stored in the the "src-cljx" folder. My
> rules then trigger generated sources into "src-clj" (for all Clojure and
> shared macros) and "src-cljs" for CLJS parts only.
> 
> My project.clj is as follows:
> 
> (defproject foo "0.1.0-SNAPSHOT"
>   :dependencies [[org.clojure/clojure "1.5.1"]
>                  [org.clojure/clojurescript "0.0-2156"]]
>  
>   :jar-exclusions [#"\.cljx|\.DS_Store|\.js|\.html"]
> 
>   :cljx {:builds [{:source-paths ["src-cljx"]
>                    :output-path "src-clj"
>                    :rules :clj}
>                   {:source-paths ["src-cljx"]
>                    :output-path "src-cljs"
>                    :rules :cljs}]}
> 
>   :cljsbuild {:builds
>               [{:id "dev"
>                 :source-paths ["src-clj" "src-cljs"]
>                 :compiler
>                 {:pretty-print true
>                  :output-to "foo-0.1.0-SNAPSHOT.js"
>                  :optimizations :simple}
>                 :jar true}]}
> 
>   :plugins [[com.keminglabs/cljx "0.3.2"]
>             [lein-cljsbuild "1.0.2"]]
>   :hooks [cljx.hooks leiningen.cljsbuild])
> 
> I can successfully create a JAR from this with `lein install`, however
> if I try to use this library as dependency in another CLJS project, none
> of the namespaces of this dependency seem to be found, even though I
> verified that they're present in the JAR (contains both .clj & .cljs
> versions).
> 
> So I then assumed the reasons for this are the non-standard names for
> the source folders. But adding this line at the root level of
> project.clj will not work either and makes `lein install` fail with a
> "java.util.zip.ZipException: duplicate entry":
> 
> :source-paths ["src-clj" "src-cljs"]
> 
> Therefore can someone please explain or point me to a correct project
> setup to make this work? I've been trying to find answers on SO &
> Google, but it seems this (strangely?) isn't a popular use case and I
> couldn't find any helpful answers.
> 
> Once this is solved am happy to write up a short tutorial or create a
> lein template for future reference.
> 
> Thank you!
> K.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to