Never use .mkdirs directly; it silently masks errors.
Use leiningen.core.utils/mkdirs so that problems will be found when they happen.
This commit is contained in:
parent
163887d097
commit
04d500103b
9 changed files with 26 additions and 16 deletions
|
@ -29,8 +29,8 @@
|
|||
:when (.startsWith (.getName entry) native-prefix)]
|
||||
(let [f (io/file native-path (subs (.getName entry) (count native-prefix)))]
|
||||
(if (.isDirectory entry)
|
||||
(.mkdirs f)
|
||||
(do (.mkdirs (.getParentFile f))
|
||||
(utils/mkdirs f)
|
||||
(do (utils/mkdirs (.getParentFile f))
|
||||
(io/copy (.getInputStream jar entry) f))))))
|
||||
|
||||
(defn extract-native-dep!
|
||||
|
@ -47,8 +47,8 @@
|
|||
(vreset! native? true)
|
||||
(let [f (io/file native-path (subs (.getName entry) (count native-prefix)))]
|
||||
(if (.isDirectory entry)
|
||||
(.mkdirs f)
|
||||
(do (.mkdirs (.getParentFile f))
|
||||
(utils/mkdirs f)
|
||||
(do (utils/mkdirs (.getParentFile f))
|
||||
(io/copy (.getInputStream jar entry) f)))))
|
||||
@native?))
|
||||
|
||||
|
@ -167,7 +167,7 @@
|
|||
(warn "Could not read the old stale value for" identifier ", rerunning stale task"))
|
||||
(when (or (= ::error file-content)
|
||||
(not= old-cmp-val cmp-val))
|
||||
(.mkdirs (.getParentFile file))
|
||||
(utils/mkdirs (.getParentFile file))
|
||||
(let [result (apply f outdated-val args)]
|
||||
(spit file (pr-str [cmp-val result]))
|
||||
result)))))
|
||||
|
@ -189,7 +189,7 @@
|
|||
(when (and (:name project) (:target-path project)
|
||||
(not= current-value old-value))
|
||||
(apply f args)
|
||||
(.mkdirs (.getParentFile file))
|
||||
(utils/mkdirs (.getParentFile file))
|
||||
(spit file (doall current-value))
|
||||
true)))
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
(when (and (:root project) (:write-pom-properties project true))
|
||||
(let [path (format "%s/META-INF/maven/%s/%s/pom.properties"
|
||||
compile-path group name)]
|
||||
(.mkdirs (.getParentFile (io/file path)))
|
||||
(utils/mkdirs (.getParentFile (io/file path)))
|
||||
(spit path (project/make-project-properties project)))))
|
||||
|
||||
(defn run-prep-tasks
|
||||
|
@ -76,11 +76,11 @@
|
|||
[project]
|
||||
;; These must exist before the project is launched.
|
||||
(when (:root project)
|
||||
(.mkdirs (io/file (:compile-path project "/tmp")))
|
||||
(utils/mkdirs (io/file (:compile-path project "/tmp")))
|
||||
;; hack to not create default projects. For now only.
|
||||
(doseq [path (mapcat #(remove-default-paths project %)
|
||||
((juxt :source-paths :test-paths :resource-paths) project))]
|
||||
(.mkdirs (io/file path))))
|
||||
(utils/mkdirs (io/file path))))
|
||||
(write-pom-properties project)
|
||||
(classpath/resolve-managed-dependencies :dependencies :managed-dependencies project)
|
||||
(run-prep-tasks project)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
(let [lein-home (getenv "LEIN_HOME")
|
||||
lein-home (or (and lein-home (io/file lein-home))
|
||||
(io/file (System/getProperty "user.home") ".lein"))]
|
||||
(.getAbsolutePath (doto lein-home .mkdirs))))
|
||||
(.getAbsolutePath (doto lein-home utils/mkdirs))))
|
||||
|
||||
;; TODO: move all these memoized fns into delays
|
||||
(def init
|
||||
|
|
|
@ -63,6 +63,12 @@
|
|||
(not= (.getCanonicalFile canon)
|
||||
(.getAbsoluteFile canon))))
|
||||
|
||||
(defn mkdirs
|
||||
"Make a given directory and its parents, but throw an Exception on failure."
|
||||
[f] ; whyyyyy does .mkdirs fail silently ugh
|
||||
(when-not (.mkdirs (io/file f))
|
||||
(throw (Exception. (str "Couldn't create directories: " (io/file f))))))
|
||||
|
||||
(defn relativize
|
||||
"Makes the filepath path relative to base. Assumes base is an ancestor to
|
||||
path, and that the path contains no '..'."
|
||||
|
|
|
@ -217,7 +217,7 @@
|
|||
|
||||
;; Split out backwards-compatibility. Collapse into get-jar-filename for 3.0
|
||||
(defn get-classified-jar-filename [project classifier]
|
||||
(let [target (doto (io/file (:target-path project)) .mkdirs)
|
||||
(let [target (doto (io/file (:target-path project)) utils/mkdirs)
|
||||
suffix (if classifier (str "-" (name classifier) ".jar") ".jar")
|
||||
name-kw (if (= classifier :standalone) :uberjar-name :jar-name)
|
||||
jar-name (or (project name-kw) (str (:name project) "-%s" suffix))
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
(:require [leiningen.classpath :as classpath]
|
||||
[leiningen.core.eval :as eval]
|
||||
[leiningen.core.main :as main]
|
||||
[leiningen.core.utils :as utils]
|
||||
[leiningen.core.project :as project]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as string])
|
||||
|
@ -91,7 +92,7 @@
|
|||
~(when main/*info*
|
||||
`(binding [*out* *err*]
|
||||
(println "Compiling" ~(count files) "source files to" ~compile-path)))
|
||||
(.mkdirs (clojure.java.io/file ~compile-path))
|
||||
(utils/mkdirs (clojure.java.io/file ~compile-path))
|
||||
(when-not (zero?
|
||||
(.run compiler# nil nil nil
|
||||
(into-array java.lang.String ~javac-opts)))
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
[clojure.string :as string]
|
||||
[leiningen.core.eval :as eval]
|
||||
[leiningen.core.user :as user]
|
||||
[leiningen.core.utils :as utils]
|
||||
[leiningen.core.main :as main]
|
||||
[stencil.core :as stencil])
|
||||
(:import (java.util Calendar)))
|
||||
|
@ -191,11 +192,11 @@
|
|||
(if (or (= "." dir) (.mkdir (io/file dir)) *force?*)
|
||||
(doseq [path paths]
|
||||
(if (string? path)
|
||||
(.mkdirs (template-path dir path data))
|
||||
(utils/mkdirs (template-path dir path data))
|
||||
(let [[path content & options] path
|
||||
path (template-path dir path data)
|
||||
options (apply hash-map options)]
|
||||
(.mkdirs (.getParentFile path))
|
||||
(utils/mkdirs (.getParentFile path))
|
||||
(io/copy content (io/file path))
|
||||
(when (:executable options)
|
||||
(.setExecutable path true)))))
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"Write a pom.xml file to disk for Maven interoperability."
|
||||
(:import java.io.IOException)
|
||||
(:require [leiningen.core.main :as main]
|
||||
[leiningen.core.utils :as utils]
|
||||
[leiningen.core.project :as project]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.set :as set]
|
||||
|
@ -402,7 +403,7 @@
|
|||
([project pom-location-or-properties]
|
||||
(let [pom (make-pom project true)
|
||||
pom-file (io/file (:root project) pom-location-or-properties)]
|
||||
(.mkdirs (.getParentFile pom-file))
|
||||
(utils/mkdirs (.getParentFile pom-file))
|
||||
(with-open [pom-writer (io/writer pom-file)]
|
||||
(.write pom-writer pom))
|
||||
(main/info "Wrote" (str pom-file))
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
(:require [clojure.string :as string]
|
||||
[leiningen.core.eval :as eval]
|
||||
[leiningen.core.main :as main]
|
||||
[leiningen.core.utils :as utils]
|
||||
[leiningen.core.project :as project]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.pprint :as pprint]))
|
||||
|
@ -34,7 +35,7 @@
|
|||
(let [command (trampoline-command-string project forms profiles)
|
||||
trampoline (trampoline-file)]
|
||||
(main/debug "Trampoline command:" command)
|
||||
(.mkdirs (.getParentFile (io/file trampoline)))
|
||||
(utils/mkdirs (.getParentFile (io/file trampoline)))
|
||||
(spit trampoline command)))
|
||||
|
||||
(defn ^:higher-order trampoline
|
||||
|
|
Loading…
Reference in a new issue