boot-clj / boot

Build tooling for Clojure.
https://boot-clj.github.io/
Eclipse Public License 1.0
1.75k stars 180 forks source link

boot show -u prints :exclusions as a vector of vectors #635

Open Jannis opened 7 years ago

Jannis commented 7 years ago

Description

When running boot show -u, it prints dependencies with exclusions like this:

[com.cemerick/piggieback "0.2.2" :scope "test" :exclusions [[com.google.guava/guava]]]
[com.datomic/datomic-free "0.9.5561.50" :scope "test" :exclusions [[com.google.guava/guava]]]

In this output, the :exclusions are incorrectly printed as a vector of vectors, where it should really be a vector of symbols.

If the above is copied into build.boot, it results in errors like this one (when running boot pom):

...
                                           clojure.core/seq                          core.clj:  137
                                                        ...
                        boot.pom/pom-xml/iter/fn/fn/iter/fn                           pom.clj:  103
                     boot.pom/pom-xml/iter/fn/fn/iter/fn/fn                           pom.clj:  103
                                      boot.util/extract-ids                          util.clj:  331
                                       clojure.core/juxt/fn                          core.clj: 2574
                                     clojure.core/namespace                          core.clj: 1594
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Named
  clojure.lang.ExceptionInfo: clojure.lang.PersistentVector cannot be cast to clojure.lang.Named
    file: "/var/folders/lv/1_kzb2t55gsbc2r0bcvm418r0000gn/T/boot.user4408150776635283384.clj"
    line: 45

Expected behavior

The expected behavior would be to print dependencies with exclusions such that the exclusions are a vector of symbols:

[com.cemerick/piggieback "0.2.2" :scope "test" :exclusions [com.google.guava/guava]]
[com.datomic/datomic-free "0.9.5561.50" :scope "test" :exclusions [com.google.guava/guava]]

Steps to reproduce

  1. Add an outdated dependency with an exclusion to the dependencies in build.boot.
  2. Run boot show -u.
martinklepsch commented 6 years ago

Seems to come out of pomegranate:

(require 'cemerick.pomegranate.aether)

(cemerick.pomegranate.aether/resolve-dependencies
 :coordinates  '[[boot/core "2.7.0" :exclusions [org.clojure/clojure]]]
 :repositories  [["clojars" {:url "https://repo.clojars.org/"}]
                 ["maven-central" {:url "https://repo1.maven.org/maven2"}]])

;; returns the following
{[boot/core "2.7.0" :exclusions [[org.clojure/clojure]]] #{[boot/pod "2.7.0"]},
 [boot/pod "2.7.0"] #{[org.tcrawley/dynapath "0.2.5"] [org.projectodd.shimdandy/shimdandy-impl "1.2.0"]},
 [org.tcrawley/dynapath "0.2.5"] nil,
 [org.projectodd.shimdandy/shimdandy-impl "1.2.0"] nil}
martinklepsch commented 6 years ago

So as per @cemerick this is intentional: https://github.com/cemerick/pomegranate/issues/93

As I understand it one can pass a vector of vectors or a vector of symbols (which is a shorthand and gets converted to a vector of vectors). So maybe we should also just do the same normalization/reverse-of-that if the exclusions are given as vector of vectors.

The code that throws the exception @Jannis mentioned is here: https://github.com/boot-clj/boot/blob/a1d19c960e0b56c2613e85ecd0059a090148cc5a/boot/worker/src/boot/pom.clj#L102-L106

p is expected to be a symbol. Simplest thing is just calling flatten on the exclusions seq. 😄