Fork me on GitHub
#tools-build
<
2023-08-22
>
Ben Lieberman15:08:04

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-johnny15:08:27

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

Ben Lieberman15:08:11

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

Ben Lieberman15:08:09

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)15:08:11

which task are we talking about?

Alex Miller (Clojure team)15:08:35

are you copying src dirs or compiling clj to classes?

Alex Miller (Clojure team)15:08:51

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

Ben Lieberman15:08:56

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)15:08:51

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)15:08:34

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

Ben Lieberman15:08:37

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

Alex Miller (Clojure team)15:08:30

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

Ben Lieberman15:08:53

Thanks for the clarification 🙏:skin-tone-2: I'll have to play around, really have not turned any tools-build knobs yet