Skip to content

Commit

Permalink
Implement system-level profiles. Fixes #981.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Feb 28, 2013
1 parent fd11857 commit f7f588b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion leiningen-core/src/leiningen/core/project.clj
Expand Up @@ -401,6 +401,9 @@

(alter-var-root #'warn-user-profile memoize)

(defn- system-profiles []
(user/load-profiles (io/file "/etc" "leiningen")))

(defn- project-profiles [project]
(let [profiles (utils/read-file (io/file (:root project) "profiles.clj"))]
(warn-user-profile profiles)
Expand All @@ -415,7 +418,7 @@
[project]
(warn-user-repos (user/profiles))
(warn-user-profile (:profiles project))
(merge @default-profiles (user/profiles)
(merge @default-profiles (system-profiles) (user/profiles)
(:profiles project) (project-profiles project)))

;; # Lower-level profile plumbing: loading plugins, hooks, middleware, certs
Expand Down
12 changes: 6 additions & 6 deletions leiningen-core/src/leiningen/core/user.clj
Expand Up @@ -40,14 +40,14 @@
"from" (str (leiningen-home) "/profiles.d:"))
(println (.getMessage e))))))))))))

(def ^:private load-profiles
"Load profiles.clj from your Leiningen home if present."
(def ^:internal load-profiles
"Load profiles.clj from dir if present."
(memoize
(fn []
(try (utils/read-file (io/file (leiningen-home) "profiles.clj"))
(fn [dir]
(try (utils/read-file (io/file dir "profiles.clj"))
(catch Exception e
(binding [*out* *err*]
(println "Error reading profiles.clj from" (leiningen-home))
(println "Error reading profiles.clj from" dir)
(println (.getMessage e))))))))

(def profiles
Expand All @@ -62,7 +62,7 @@
"in the profiles.d directory."))
(throw (Exception. "Multiple profiles defined in ~/.lein")))]
(try (apply merge-with error-fn
(load-profiles) (profiles-d-profiles))
(load-profiles (leiningen-home)) (profiles-d-profiles))
(catch Exception e))))))

(defn gpg-program
Expand Down

0 comments on commit f7f588b

Please sign in to comment.