From 9e639dc6c09279c0f7f6155533cf677790bff3ca Mon Sep 17 00:00:00 2001 From: Chris Price Date: Tue, 1 Nov 2016 15:18:39 -0700 Subject: [PATCH] Add support for lein 2.7's `:managed-dependencies` --- plugin/project.clj | 4 +-- plugin/src/leiningen/cljsbuild/subproject.clj | 30 ++++++++++++++----- support/project.clj | 2 +- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/plugin/project.clj b/plugin/project.clj index 9996069a..723507d2 100644 --- a/plugin/project.clj +++ b/plugin/project.clj @@ -1,4 +1,4 @@ -(defproject lein-cljsbuild "1.1.4" +(defproject lein-cljsbuild "1.1.5-SNAPSHOT" :description "ClojureScript Autobuilder Plugin" :url "http://github.com/emezeske/lein-cljsbuild" :license @@ -10,6 +10,6 @@ :dev { :dependencies [ [midje "1.6.3"] - [cljsbuild "1.1.4"]] + [cljsbuild "1.1.5-SNAPSHOT"]] :plugins [[lein-midje "3.1.3"]]}} :eval-in-leiningen true) diff --git a/plugin/src/leiningen/cljsbuild/subproject.clj b/plugin/src/leiningen/cljsbuild/subproject.clj index 81c45bd1..c97477ce 100644 --- a/plugin/src/leiningen/cljsbuild/subproject.clj +++ b/plugin/src/leiningen/cljsbuild/subproject.clj @@ -3,7 +3,8 @@ (:require [leiningen.core.main :as lmain] [clojure.java.io :refer (resource)] - [clojure.string :as string])) + [clojure.string :as string] + [leiningen.core.classpath :as classpath])) (def cljsbuild-version (let [[_ coords version] @@ -70,14 +71,27 @@ (->> (reduce-kv array-map-assoc cljsbuild project) (map (fn [[k v]] (vec (cons k v))))))) +(defn- get-deps-from-project + [project] + ;; This checks to see if the user is running lein 2.7 or greater, and, if so, + ;; merges in the dependency versions from the `:managed-dependencies` vector. + (if-let [merge-versions-from-managed-coords (resolve 'leiningen.core.classpath/merge-versions-from-managed-coords)] + (merge-versions-from-managed-coords + (get project :dependencies) + (get project :managed-dependencies)) + (get project :dependencies))) + (defn make-subproject [project crossover-path builds] - (with-meta - (merge + (let [deps (get-deps-from-project project)] + (with-meta + (merge project {:local-repo-classpath true - :dependencies (merge-dependencies (:dependencies project)) + :dependencies (merge-dependencies deps) :source-paths (concat - (:source-paths project) - (mapcat :source-paths builds) - [crossover-path])}) - (meta project))) + (:source-paths project) + (mapcat :source-paths builds) + [crossover-path])}) + (meta project)))) + + diff --git a/support/project.clj b/support/project.clj index e601e517..5dc3b3f5 100644 --- a/support/project.clj +++ b/support/project.clj @@ -1,4 +1,4 @@ -(defproject cljsbuild "1.1.4" +(defproject cljsbuild "1.1.5-SNAPSHOT" :description "ClojureScript Autobuilder" :url "http://github.com/emezeske/lein-cljsbuild" :license