Why most of the tools.build compile-clj usages I see have either before or after a copy-dir with the "src" dir along the "resources"?
E.g. from the official https://clojure.org/guides/tools_build:
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/compile-clj {:basis @basis
:ns-compile '[my.lib.main]
:class-dir class-dir})
Or from deps-new https://github.com/seancorfield/deps-new/blob/515dd2547bcdd5890a8fbf64e2ce26c088e1c93f/resources/org/corfield/new/app/build/build.tmpl#L36:
(b/copy-dir {:src-dirs ["resources" "src"] :target-dir class-dir})
(b/compile-clj { ... :class-dir class-dir :src-dirs ["src"] ... })
I thought that when (pre)compiling clojure code the original sources are redundant, and that maybe they shouldn't be included in the copy-dir :src-dirs?You dont necessarily need to copy the the src
But if you’re going to use the doc function etc those require the src files
Ah I see, it makes sense
I suppose they are also needed for the stack traces?
no
they aren't actually needed for doc either, but for source
Ah that makes sense, thank you for the info!
I imagine it is mostly included in the examples because it is what other clojure build tools (like lein) do by default
If your main ns doesn't transitive reach all your source files -- perhaps because one or more nses are dynamically required at runtime -- then you'll need to copy those files (since they won't be compiled). I think Clojure itself has one of these (the instant time stuff?).
That was true at one point, but has not been for a while
Because we no longer have to support JDK 7 and earlier, right?
(I have projects that have dynamically required nses so those don't get transitively compiled, as I recall)