Skip to content

Commit

Permalink
Fix #465: Use full project map for subproject.
Browse files Browse the repository at this point in the history
Previously, when we would just select a few keys from the project map
for the subproject, we would not include the :root key. The root key
specifies the path to the project directory. It is used to set the
working directory when starting a new subprocess. Not having the root
key in the subproject map would cause problems when using lein-monolith
since the working directory would not be set correctly.
  • Loading branch information
mneise committed Jul 15, 2017
1 parent 018c5f9 commit 0d085f9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion example-projects/advanced/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:exclusions [org.apache.ant/ant]]
[compojure "1.1.6"]
[hiccup "1.0.4"]]
:plugins [[lein-cljsbuild "1.1.6"]
:plugins [[lein-cljsbuild "1.1.7-SNAPSHOT"]
[lein-ring "0.8.7"]]
; Enable the lein hooks for: compile, test, and jar.
:hooks [leiningen.cljsbuild]
Expand Down
2 changes: 1 addition & 1 deletion example-projects/none/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.521"]]

:plugins [[lein-cljsbuild "1.1.6"]]
:plugins [[lein-cljsbuild "1.1.7-SNAPSHOT"]]

:source-paths ["src"]

Expand Down
2 changes: 1 addition & 1 deletion example-projects/simple/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:exclusions [org.apache.ant/ant]]
[compojure "1.1.6"]
[hiccup "1.0.4"]]
:plugins [[lein-cljsbuild "1.1.6"]
:plugins [[lein-cljsbuild "1.1.7-SNAPSHOT"]
[lein-ring "0.8.7"]]
:cljsbuild {
:builds [{:source-paths ["src-cljs"]
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/leiningen/cljsbuild.clj
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
(apply task [project out-file (concat filespecs (jar/get-filespecs project))]))

(defn activate
"Set up hooks for the plugin. Eventually, this can be changed to just hook,
"Set up hooks for the plugin. Eventually, this can be changed to just hook,
and people won't have to specify :hooks in their project.clj files anymore."
[]
(hooke/add-hook #'lcompile/compile #'compile-hook)
Expand Down
3 changes: 1 addition & 2 deletions plugin/src/leiningen/cljsbuild/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@
(defn- set-default-output-dirs [target-path options]
(let [output-dir-key [:compiler :output-dir]
relative-target-path (when target-path
(util/relative-path (str (System/getProperty "user.dir")
(System/getProperty "file.separator")) target-path))
(util/relative-path (util/get-working-dir) target-path))
builds
(for [[build counter] (map vector (:builds options) (range))]
(if (get-in build output-dir-key)
Expand Down
18 changes: 9 additions & 9 deletions plugin/src/leiningen/cljsbuild/subproject.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@
(get project :dependencies)))

(defn make-subproject [project crossover-path builds]
(let [deps (get-deps-from-project project)]
(let [deps (get-deps-from-project project)
remove-compile-task (fn [tasks]
(remove (fn [task]
(= task "compile"))
tasks))]
(with-meta
(merge
(select-keys project [:checkout-deps-shares
:eval-in
:jvm-opts
:local-repo
:repositories
:mirrors
:resource-paths])
;; Leiningen sets javac and compile as default prep-tasks. We need to remove
;; the compile task, so it doesn't trigger the compile hook for all builds.
;; https://github.com/emezeske/lein-cljsbuild/issues/451
(merge (update project :prep-tasks remove-compile-task)
{:local-repo-classpath true
:dependencies (merge-dependencies deps)
:source-paths (concat
Expand Down
10 changes: 8 additions & 2 deletions plugin/src/leiningen/cljsbuild/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
[clojure.string :as s]))

(defn relative-path
"Given two normalized path strings, returns a path string of the second relative to the first.
Otherwise returns the second path."
"Given two normalized path strings, returns a path string of the second
relative to the first. Otherwise returns the second path."
[parent child]
(let [relative (s/replace child parent "")]
(if (= child relative)
child
(s/replace relative #"^[\\/]" ""))))

(defn get-working-dir
"Returns the full path to the working directory, which is the directory the
build was started in."
[]
(str (System/getProperty "user.dir")))

0 comments on commit 0d085f9

Please sign in to comment.