3

using lein for clojure, attempting to use the clojurescript plugin. followed all readme.md install steps, project.clj has

  :dependencies [[org.clojure/clojure "1.7.0"]
                [org.clojure/clojurescript "0.0-3126"]]
  ;; lein-cljsbuild plugin to build a CLJS project  
  :plugins [[lein-cljsbuild "1.0.6"]]  
  :hooks [leiningen.cljsbuild]

I cannot seem to get lein to recognize the plugin and am not sure what is being the gremlin.

C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein cljsbuild once
'cljsbuild' is not a task. See 'lein help'.
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein compile
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein cljsbuild once
'cljsbuild' is not a task. See 'lein help'.
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein -v
Leiningen 2.5.1 on Java 1.8.0_51 Java HotSpot(TM) 64-Bit Server VM
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>
  • 1
    Could you please show which command you are executing and the full output you get? Would also be of help if you show the entire project.clj – nberger Jul 20 '15 at 02:37
  • 2
    `lein help` will show the available tasks. Does "cljsbuild" appear there? It might be something with your environment, but I don't use leiningen in windows, so I can't be of much help. You could check the install instructions of leiningen to see if you missed something: https://github.com/technomancy/leiningen#windows – nberger Jul 20 '15 at 02:52

2 Answers2

5

If you use lein new mies ... for getting the project file, and execute the command, the automatically generated project.clj file should be modified. This is an example that shows the change:

Before:

(defproject simple "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.122" :classifier "aot"
                  :exclusion [org.clojure/data.json]]
                 [org.clojure/data.json "0.2.6" :classifier "aot"]]
  :jvm-opts ^:replace ["-Xmx1g" "-server"]
  :plugins [[lein-npm "0.6.1"]]
  :npm {:dependencies [[source-map-support "0.3.2"]]}
  :source-paths ["src" "target/classes"]
  :clean-targets ["out" "release"]
  :target-path "target")

After

(defproject simple "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.122" :classifier "aot"
                  :exclusion [org.clojure/data.json]]
                 [org.clojure/data.json "0.2.6" :classifier "aot"]]

  :node-dependencies [[source-map-support "0.2.8"]]

  :jvm-opts ^:replace ["-Xmx1g" "-server"]

  :plugins [[lein-npm "0.6.1"] 
            [lein-cljsbuild "1.0.4"]]

  :npm {:dependencies [[source-map-support "0.3.2"]]}
  :source-paths ["src" "target/classes"]
  :clean-targets ["out" "release"]
  :target-path "target"

  :cljsbuild {
      :builds [{:id "simple"
                :source-paths ["src"]
                :compiler {
                    :main simple.core
                    :output-to "out/simple.js"
                    :output-dir "out"
                    :optimizations :none
                    :target :nodejs
                    :cache-analysis true
                    :source-map true}}]})

As you see, you need to add lein-cljsbuild plugins with build information. For further explanation, refer to http://www.mase.io/code/clojure/node/2015/01/24/getting-started-with-clojurecript-and-node/

If you don't want the change, just run ./scripts/build.

prosseek
  • 182,215
  • 215
  • 566
  • 871
  • also note ./scripts/watch will trigger the Clojure code, under the compiler in auto watch mode. – Dan Jay Jan 01 '16 at 10:53
3

I think the problem is that your project.clj file is lacking a :cljsbuild stanza/key which defines the various parameters required to compile the clojurescript source files.

Have a look at Modern Clojurescript Tutorial for more details or you can check out my clojurescript file upload example to get an idea of how you can define :cljsbuild targets.

Tim X
  • 4,158
  • 1
  • 20
  • 26