Skip to content

Commit

Permalink
Merge pull request #1704 from hugoduncan/feature/add-task-profile-meta
Browse files Browse the repository at this point in the history
Allow multiple repl task profiles
  • Loading branch information
technomancy committed Oct 12, 2014
2 parents 37f3c25 + e946ad1 commit fa64351
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 10 additions & 1 deletion leiningen-core/src/leiningen/core/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@
:test {:pom-scope :test}
:base {:pom-scope :test}
:uberjar {:leaky true}
:provided {:pom-scope :provided}})
:provided {:pom-scope :provided}
:repl {:repl true}})

(defn- meta-merge
"Recursively merge values based on the information in their metadata."
Expand Down Expand Up @@ -905,6 +906,14 @@ Also merges default profiles."
(-> project meta :profile-inherited-meta))
(into {})))

(defn profiles-with-matching-meta
"Return a sequence of profile keywords for the project profiles that
have metadata that satisfies the predicate, pred."
[project pred]
(->> (-> project meta :profiles)
(filter (comp pred meta val))
(map key)))

(defn non-leaky-profiles
"Return a sequence of profile keywords for the non-leaky profiles
currently included in the project."
Expand Down
6 changes: 3 additions & 3 deletions leiningen-core/src/leiningen/core/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
[file]
(try
(let [kw (->> file .getName (re-find #".+(?=\.clj)") keyword)
contents (with-meta (utils/read-file file) ;; assumes the file exist
{:origin (.getAbsolutePath file)})]
contents (vary-meta (utils/read-file file) ;; assumes the file exist
merge {:origin (.getAbsolutePath file)})]
[kw contents])
(catch Exception e
(binding [*out* *err*]
Expand All @@ -65,7 +65,7 @@
(memoize
(fn [dir]
(if-let [contents (utils/read-file (io/file dir "profiles.clj"))]
(utils/map-vals contents with-meta
(utils/map-vals contents vary-meta merge
{:origin (str (io/file dir "profiles.clj"))})))))


Expand Down
4 changes: 3 additions & 1 deletion src/leiningen/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ deactivated, but it can be overridden."

([project] (repl project ":start"))
([project subcommand & opts]
(let [project (project/merge-profiles project [:repl])]
(let [project (project/merge-profiles
project
(project/profiles-with-matching-meta project :repl))]
(if (= subcommand ":connect")
(client project (doto (connect-string project opts)
(->> (main/info "Connecting to nREPL at"))))
Expand Down

0 comments on commit fa64351

Please sign in to comment.