Skip to content

Commit

Permalink
treat deps.edn git deps as if from .jar
Browse files Browse the repository at this point in the history
otherwise they are treated as project files and warn more than
they should.

fixes #580
  • Loading branch information
thheller committed Oct 28, 2019
1 parent 8921431 commit 06746be
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 25 additions & 2 deletions src/main/shadow/build/classpath.clj
Expand Up @@ -573,10 +573,27 @@
:file file
:url (.toURL file)}))

(defn is-gitlib-file? [^File file]
(loop [file (.getAbsoluteFile file)]
(cond
(nil? file)
false

(and (.exists file) (.isDirectory file) (= ".gitlibs" (.getName file)))
true

:else
(recur (.getParentFile file)))))

(comment
(is-gitlib-file? (io/file "src" "main" "shadow" "build.clj"))
(is-gitlib-file? (io/file (System/getProperty "user.home") ".gitlibs" "libs")))

(defn find-fs-resources*
[cp ^File root]
(let [root-path (.getCanonicalPath root)
root-len (inc (count root-path))]
root-len (inc (count root-path))
is-gitlib-root? (is-gitlib-file? root)]
(into []
(for [^File file (file-seq root)
:when (and (.isFile file)
Expand All @@ -590,7 +607,12 @@
(rc/normalize-name))]
:when (not (should-ignore-resource? cp name))]

(make-fs-resource file name)
(-> (make-fs-resource file name)
;; treat gitlibs as if they were from a .jar
;; affects hot-reload and warnings logic
(cond->
is-gitlib-root?
(assoc :from-jar true)))
))))

(defn find-fs-resources [cp ^File root]
Expand All @@ -604,6 +626,7 @@

(.isDirectory file)
(find-fs-resources cp file)

(and (.isFile file) (util/is-jar? (.getName file)))
(find-jar-resources cp file)

Expand Down
4 changes: 2 additions & 2 deletions src/main/shadow/build/compiler.clj
Expand Up @@ -463,7 +463,7 @@

(defn do-compile-cljs-resource
[{:keys [compiler-options] :as state}
{:keys [resource-id resource-name url file output-name] :as rc}
{:keys [resource-id resource-name from-jar] :as rc}
source]
(let [{:keys [warnings static-fns elide-asserts load-tests fn-invoke-direct infer-externs form-size-threshold]}
compiler-options]
Expand All @@ -487,7 +487,7 @@
(-> ana/*cljs-warnings*
(merge warnings)
(cond->
(or (and file (= :auto infer-externs))
(or (and (= :auto infer-externs) (not from-jar))
(= :all infer-externs))
(assoc :infer-warning true)))

Expand Down

0 comments on commit 06746be

Please sign in to comment.