Clojure lein run退出,但不运行所有my-main函数
这是我的Clojure lein run退出,但不运行所有my-main函数,clojure,leiningen,Clojure,Leiningen,这是我的项目。clj: (defproject fixurls "0.1.0-SNAPSHOT" :description "Fixurls" :url "https://github.com/swizzard/fixurls" :license {:name "WTFPL" :url "http://www.wtfpl.net/"} :dependencies [[org.clojure/clojure "1.5.1"]
项目。clj
:
(defproject fixurls "0.1.0-SNAPSHOT"
:description "Fixurls"
:url "https://github.com/swizzard/fixurls"
:license {:name "WTFPL"
:url "http://www.wtfpl.net/"}
:dependencies [[org.clojure/clojure "1.5.1"]
[clj-http "0.9.2"]
[org.clojure/data.json "0.2.4"]
[me.raynes/fs "1.4.4"]
]
:plugins [[lein-gorilla "0.2.0"]]
:jvm-opts ["-Xmx4g" "-Xms2g" "-Xss1g" "-server"]
:main ^:skip-aot fixurls.core
)
(ns fixurls.core
(:require
[clj-http.client :as client]
[clojure.string :as string]
[clojure.java.io :as io]
[me.raynes.fs :as fs]
[clojure.data.json :as json]
)
(:import [java.net URL])
(:gen-class)
)
...
(defn process-file [in-file] (spit (get-fixed-name in-file)
(update-file in-file)))
(defn process-files [] (map process-file valid-files))
(defn -main [] (do (println "Hello, world!") (process-files)))
下面是~/clojure stuff/fixURL/src/core.clj
:
(defproject fixurls "0.1.0-SNAPSHOT"
:description "Fixurls"
:url "https://github.com/swizzard/fixurls"
:license {:name "WTFPL"
:url "http://www.wtfpl.net/"}
:dependencies [[org.clojure/clojure "1.5.1"]
[clj-http "0.9.2"]
[org.clojure/data.json "0.2.4"]
[me.raynes/fs "1.4.4"]
]
:plugins [[lein-gorilla "0.2.0"]]
:jvm-opts ["-Xmx4g" "-Xms2g" "-Xss1g" "-server"]
:main ^:skip-aot fixurls.core
)
(ns fixurls.core
(:require
[clj-http.client :as client]
[clojure.string :as string]
[clojure.java.io :as io]
[me.raynes.fs :as fs]
[clojure.data.json :as json]
)
(:import [java.net URL])
(:gen-class)
)
...
(defn process-file [in-file] (spit (get-fixed-name in-file)
(update-file in-file)))
(defn process-files [] (map process-file valid-files))
(defn -main [] (do (println "Hello, world!") (process-files)))
当我运行
lein run
时,暂停一段时间后,所发生的一切就是打印你好,世界
到stdout,然后lein退出。我已经独立验证了-main
的(进程文件)
部分没有被调用。我可以从repl运行(-main)
,它工作正常。我做错了什么?映射函数是惰性的,除非访问相应的输出,否则不能保证处理任何输入。如果您使用map
仅用于副作用,请将其包装在dorun
中。如果您还需要结果,请使用doall
强制处理整个输入。有效。谢谢我想我还是要把我的头缠在懒惰的东西上。。。