Skip to content

Commit

Permalink
Warn when trying to load plugins that can't be used.
Browse files Browse the repository at this point in the history
This addresses the problems seen in #1900 and #1901. It doesn't fix
them because they can't be fixed without breaking other things,
(technomancy/grenchman#34) but at least it
lets people know what is going on and suggests a workaround.
  • Loading branch information
technomancy committed Mar 28, 2017
1 parent 170e0cb commit aaa3ef1
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
23 changes: 23 additions & 0 deletions leiningen-core/src/leiningen/core/classpath.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
(require 'leiningen.core.main)
(apply (resolve 'leiningen.core.main/warn) args))

(def ^:private warn-once (memoize warn))

(defn ^:deprecated extract-native-deps [files native-path native-prefixes]
(doseq [file files
:let [native-prefix (get native-prefixes file "native/")
Expand Down Expand Up @@ -493,6 +495,24 @@
(doseq [[_ {:keys [native-prefix file]}] snap-deps]
(extract-native-dep! native-path file native-prefix))))))

(def ^:private bootclasspath-deps (-> "leiningen/bootclasspath-deps.clj"
io/resource slurp read-string))

(defn- warn-conflicts
"When using the bootclasspath (for boot speed), resources already on the
bootclasspath cannot be overridden by plugins, so notify the user about it."
[project dependencies]
(let [warned (atom false)]
(doseq [[artifact version] dependencies
:when (and (bootclasspath-deps artifact)
(not= (bootclasspath-deps artifact) version))]
(reset! warned true)
(warn-once "Tried to load" artifact "version" version "but"
(bootclasspath-deps artifact) "was already loaded."))
(when (and @warned (not (:root project)))
(warn-once "You can set :eval-in :subprocess in your :user profile;"
"however this will increase repl load time."))))

(defn resolve-managed-dependencies
"Delegate dependencies to pomegranate. This will ensure they are
downloaded into ~/.m2/repository and that native components of
Expand All @@ -511,6 +531,9 @@
jars (->> dependencies-tree
(aether/dependency-files)
(filter #(re-find #"\.(jar|zip)$" (.getName %))))]
(when (some #{:add-classpath?} rest)
(warn-conflicts project (concat (keys dependencies-tree)
(reduce into (vals dependencies-tree)))))
(when (and (= :dependencies dependencies-key)
(:root project))
(extract-native-dependencies project jars dependencies-tree))
Expand Down
69 changes: 69 additions & 0 deletions resources/leiningen/bootclasspath-deps.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
;; This file is used to warn users when they attempt to load a plugin that
;; pulls in a dependency which conflicts with something already in use
;; by Leiningen itself.
{
;; Unhelpful to warn on these:
;; org.clojure/clojure "1.8.0"
;; leiningen-core "2.7.2-SNAPSHOT"
bultitude "0.2.8"
cheshire "5.6.3"
clj-http "2.0.1"
clj-stacktrace "0.2.7"
clj-tuple "0.2.2"
clojure-complete "0.2.4"
com.cemerick/drawbridge "0.0.6"
com.cemerick/pomegranate "0.3.1"
com.fasterxml.jackson.core/jackson-core "2.7.5"
com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.7.5"
com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.7.5"
com.hypirion/io "0.3.1"
commons-codec "1.10"
commons-io "2.5"
commons-lang "2.6"
commons-logging "1.1.3"
jline "2.12.1"
net.cgrand/parsley "0.9.3"
net.cgrand/regex "1.1.0"
net.cgrand/sjacket "0.1.1"
org.apache.httpcomponents/httpclient "4.5"
org.apache.httpcomponents/httpcore "4.4.1"
org.apache.httpcomponents/httpmime "4.5"
org.apache.maven.wagon/wagon-http "2.10"
org.apache.maven.wagon/wagon-http-shared "2.10"
org.apache.maven.wagon/wagon-provider-api "2.2"
org.apache.maven/maven-aether-provider "3.0.4"
org.apache.maven/maven-model "3.0.4"
org.apache.maven/maven-model-builder "3.0.4"
org.apache.maven/maven-repository-metadata "3.0.4"
org.clojure/data.xml "0.0.8"
org.clojure/tools.cli "0.3.1"
org.clojure/tools.macro "0.1.5"
org.clojure/tools.nrepl "0.2.12"
org.codehaus.plexus/plexus-classworlds "2.4"
org.codehaus.plexus/plexus-component-annotations "1.5.5"
org.codehaus.plexus/plexus-interpolation "1.14"
org.codehaus.plexus/plexus-utils "2.0.6"
org.flatland/classlojure "0.7.1"
org.jsoup/jsoup "1.7.2"
org.sonatype.aether/aether-api "1.13.1"
org.sonatype.aether/aether-connector-file "1.13.1"
org.sonatype.aether/aether-connector-wagon "1.13.1"
org.sonatype.aether/aether-impl "1.13.1"
org.sonatype.aether/aether-spi "1.13.1"
org.sonatype.aether/aether-util "1.13.1"
org.sonatype.sisu/sisu-guice "3.0.3" :classifier "no_aop"
org.sonatype.sisu/sisu-inject-bean "2.2.3"
org.sonatype.sisu/sisu-inject-plexus "2.2.3"
org.tcrawley/dynapath "0.2.5"
pedantic "0.2.0"
potemkin "0.4.1"
quoin "0.1.2"
reply "0.3.7"
riddley "0.1.10"
robert/hooke "1.3.0"
scout "0.1.1"
slingshot "0.12.2"
stencil "0.5.0"
tigris "0.1.1"
trptcolin/versioneer "0.1.1"
}

0 comments on commit aaa3ef1

Please sign in to comment.