Fork me on GitHub

How do I include non clj files from an external lib. Specifically the cognitect aws lib depends on service.edn files. I made an intermediate library that depends on

Alex Miller (Clojure team)12:05:12

If you depend on a lib, anything in it will be on the classpath and loadable as a resource

Alex Miller (Clojure team)12:05:29

But not sure if that's what you're asking


I see so it should work


  "Watch deps.edn for changes"
  (:require [ :as cp]
            [clojure.string :as str]
            [ :as deps]
            [lambdaisland.classpath :as licp]
            [nextjournal.beholder :as beholder]))

(def watcher (atom nil))

(defn- on-event [opts {:keys [type path]}]
  (when (and (= :modify type)
             ;; On Mac the path will be absolute and include the watched dir,
             ;; e.g. `/Users/x/project/./deps.edn`
             ;; On other systems it seems to be relative, like `./deps.edn`
             (str/ends-with? (str path) "./deps.edn"))
    (println "✨ Reloading deps.edn ✨")
    (let [new-paths (remove (set (map str (cp/system-classpath)))
                            (:classpath-roots (deps/create-basis opts)))]
      (doseq [path new-paths]
        (println "- " path))
      (licp/install-priority-loader! new-paths))))

(defn start!
  "Start a file system watcher to pick up changes in `deps.edn'

  Options are passed on to tools.deps when creating the basis, you probably want
  to at least put the `:aliases` you need in there.

(start! {:aliases [:dev :test]})
  (swap! watcher
         (fn [w]
           (when w
             (println "Stopping existing `deps.edn' watcher")
             (beholder/stop w))
           (beholder/watch (partial on-event opts) "."))))

(defn stop!
  "Stop a previously started watcher"
  (swap! watcher
         (fn [w]
           (when w
             (beholder/stop w))

  (start! {:aliases [:dev]}))
there is something about how this tool works that made it so I ended up with the error "could not find redshift-something.service.edn" on the classpath. It worked when I started the program. So I have libA depends on and programB depends on libA and ran into the error