tools-build

liebs 2023-08-22T15:08:04.021139Z

Does tools-build require the :src-dir to be in the project root? I've got some code I don't want to package with the JAR (though if there's good reasons not to take this approach I'm open to them). Consequently, I have my root src directory with a handful of subdirectories, and I only wish to package one of those. That has roughly this structure:

- src
  - com
    - me
      a-file.clj
but when I load the JAR it can't find a-file.clj

practicalli-johnny 2023-08-22T15:39:27.992199Z

Is it because the file name uses a - rather than _

liebs 2023-08-22T15:40:11.620579Z

no, that's a poor choice of example on my part I suppose, the file is named api.clj

liebs 2023-08-22T15:44:09.072049Z

If I pass in the directory I want as my :src-dir the outputted classes directory contains a file named api.clj but even clj-kondo complains about the namespace mismatch and then I can't load the ns in the REPL

Alex Miller (Clojure team) 2023-08-22T15:50:11.266319Z

which task are we talking about?

Alex Miller (Clojure team) 2023-08-22T15:51:35.043819Z

are you copying src dirs or compiling clj to classes?

Alex Miller (Clojure team) 2023-08-22T15:51:51.942169Z

if the former, you can selectively copy whatever you want. if the latter, you can selectively compile whatever you want

liebs 2023-08-22T15:52:56.105429Z

I think I figured it out but I suppose it would be both/either of b/write-pom and b/copy-dir. Should my POM also be modified in <sourceDirectory> ?

Alex Miller (Clojure team) 2023-08-22T15:54:51.237239Z

write-pom just write stuff in the META-INF, so this seems likely a completely different question than prior. the pom template is assumed to be in <root>/pom.xml but you can specify it to read from wherever you want

Alex Miller (Clojure team) 2023-08-22T15:55:34.197179Z

if you are only including a subset of your source, you may find it helpful for your sanity to split that into separate directory roots

liebs 2023-08-22T15:55:37.160699Z

I see. I thought b/write-pom had some bearing on the root pom.xml but TIL.

Alex Miller (Clojure team) 2023-08-22T15:56:11.058029Z

https://clojure.github.io/tools.build/clojure.tools.build.api.html#var-write-pom

πŸ˜Άβ€πŸŒ«οΈ 1
Alex Miller (Clojure team) 2023-08-22T15:56:30.268669Z

reads template from :src-pom, modifies based on basis and other args, writes to :class-dir

liebs 2023-08-22T15:59:53.721819Z

Thanks for the clarification πŸ™πŸ» I'll have to play around, really have not turned any tools-build knobs yet