Closed jpmonettas closed 9 months ago
OK, sounds reasonable. I would take a patch for this.
@technomancy The problem is related to how [org.clojure/clojure "1.11.1" :exclusions [[org.clojure/clojure]]]
is handled.
For building the java -classpath ...
command for starting the JVM process lein is currently callingleiningen.core.classpath/get-classpath
with a project that contains :dependencies [... [org.clojure/clojure "1.11.1" :exclusions [[org.clojure/clojure]]]]
which in turn calls cemerick.pomegranate.aether/dependency-files
which doesn't take into account exclusions (it just returns the jar file on the coordinates meta).
So my question is, should something like [org.clojure/clojure "1.11.1" :exclusions [[org.clojure/clojure]]]
be there in the first place? Should it be discarded as early as possible (like by leiningen.core.project/init-project
), or we want to keep that and discard it before building a classpath?
So my question is, should something like [org.clojure/clojure "1.11.1" :exclusions [[org.clojure/clojure]]] be there in the first place? Should it be discarded as early as possible (like by leiningen.core.project/init-project), or we want to keep that and discard it before building a classpath?
Yes, great question. The details of how the project is initialized are subtle, but I think the best place to handle this would be around init-project
, or to be more specific, the add-global-exclusions
function which is called by init-profiles
. Here we are are already looking at top-level :exclusions
and splicing them into the individual :dependencies
vectors.
I think this would be the ideal point to filter out "self-contradictory" dependency entries like [org.clojure/clojure "1.11.1" :exclusions [[org.clojure/clojure]]
.
Does that make sense?
@technomancy Sure make sense. add-global-exclusions
could do a (->> keep (into []) instead of a mapv and get rid of the "self-contradictory" ones there, or if we want to keep the names cleaner (add-* shouldn't be removing dependencies) we could add a extra step in init-profiles
pipe, right after add-global-exclusions
, something like remove-self-excluded-deps
to do the filtering, which I think it is clenner.
Sure; another option could be to rename add-global-exclusions
to add-and-apply-global-exclusions
so it would be clearer that it's actively excluding things. But it's up to you; either way works.
Forgot to close this; it's now implemented. Thanks again.
Currently adding a global
:exclusions
in a profile doesn't remove dependencies added directly in the main:dependencies
vector.This is useful when you want your personal profile to remove a dependency for development without having to comment out dependencies in your root vector.
For a concrete example, for using ClojureStorm with FlowStorm you need to be able to swap the official Clojure compiler by the ClojureStorm dev compiler.
The way to do this is to configure your project.clj like this :
where you exclude
org.clojure/clojure
to includecom.github.flow-storm/clojure
which provides a compiler replacement under a different group. The problem is this doesn't work unless you comment out theorg.clojure/clojure
dependency.To Reproduce Steps to reproduce the behavior:
Clojure 1.11.1-17
org.clojure/clojure
dependency while keeping the exclusionClojure 1.11.1
, which means the exlcusion did not applyThis is independent of lein, OS, and jvm version