Here's my project.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
)
Here's ~/clojure-stuff/fixurls/src/core.clj
:
(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)))
When I run lein run
, all that happens, after a pause, is the printing of Hello, world!
to stdout
, and then lein exits. I've independently verified that the (process-files)
part of -main
isn't getting called. I can run (-main)
from the repl and it works properly. What am I doing wrong?
The
map
function is lazy, and is not guaranteed process any input unless the corresponding output is accessed. If you are usingmap
for side effects alone, wrap it indorun
. If you also need the result, usedoall
to force processing of the entire input.