Fork me on GitHub
#cljdoc
<
2023-08-22
>
Ben Lieberman16:08:10

hi, first time deploying a library and I'm having some trouble getting cljdoc to discover my sources. The build is throwing a FileNotFoundException when loading the public API namespace for my lib. If I load the JAR locally though, I can access this ns without any issues.

seancorfield16:08:30

It's probably going to be down to the contents of the pom.xml file in the JAR. Which lib/version are you talking about?

seancorfield17:08:32

I suspect this is your culprit: <sourceDirectory>src/com/slothrop/clj_baseball</sourceDirectory> -- should just be <sourceDirectory>src</sourceDirectory>

2
seancorfield17:08:39

(in your pom.xml)

Ben Lieberman17:08:20

Thanks! I was confused about that, I thought it had to match the directory I copied in my build.clj.

lread20:08:19

Hey @U03QBKTVA0N I don't know if you sorted this one out. But if I look at the failing cljdoc build, I see:

Could not locate com/slothrop/clj_baseball/api__init.class, com/slothrop/clj_baseball/api.clj or com/slothrop/clj_baseball/api.cljc on classpath
But if I download the library jar from clojars: https://repo.clojars.org/org/clojars/slothrop/clj-baseball/0.3.2/clj-baseball-0.3.2.jar And then take a look at the contents:
$ unzip -l ~/Downloads/clj-baseball-0.3.2.jar                                                                                                    ✔  04:10:30 PM  
Archive:  /home/lee/Downloads/clj-baseball-0.3.2.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
       82  2023-08-22 10:01   META-INF/MANIFEST.MF
      316  2023-08-22 10:14   api.clj
        0  2023-08-22 12:01   statcast/
        0  2023-08-22 12:01   player/
        0  2023-08-22 12:01   META-INF/
     4523  2023-08-22 10:15   statcast/results_spec.clj
     3740  2023-08-22 10:14   statcast/batter.clj
      787  2023-08-22 10:15   statcast/utils.clj
    12236  2023-08-22 10:15   statcast/specs.clj
     3658  2023-08-22 11:33   player/lookup.clj
      904  2023-08-22 10:14   player/profile_spec.clj
        0  2023-08-22 12:01   META-INF/maven/
        0  2023-08-22 12:01   META-INF/maven/slothrop/
        0  2023-08-22 12:01   META-INF/maven/slothrop/clj-baseball/
      124  2023-08-22 12:01   META-INF/maven/slothrop/clj-baseball/pom.properties
     2145  2023-08-22 12:01   META-INF/maven/slothrop/clj-baseball/pom.xml
---------                     -------
    28515                     16 files
That api.clj in the root of the jar seems suspicious... it should probably be under com/slothrop/clj_baseball/api.clj, no? The other sources seem suspicious too. Dir structure in your jar should match your https://github.com/bhlieberman/clj-baseball/tree/master/src dir (minus the src dir). I think something is off with your jar building.

Ben Lieberman20:08:06

hey, yeah, I think it is. I'm gonna reorg the whole src directory again bc I've definitely messed something up.

Ben Lieberman20:08:41

The reason I did it this way was some of those subdirs are still in the works and I didn't want to include them in the jar

lread20:08:22

In an ideal world you'd want your jar sources to match your git sources at time of release. My take: it is easier to stay sane this way. You could move wip to a branch... and keep your build simple. Or if you prefer to work this way (no judgement here), you'll need to modify what goes into your jar. Perhaps the :include option on https://clojure.github.io/tools.build/clojure.tools.build.api.html#var-copy-dir would help you. Or do your own custom copy or fixup with deletes afterwards.

Ben Lieberman20:08:25

the branch is a good idea, I think. I'm fine with that. I'm a bit clueless when it comes to Java packaging and all its details so the less knobs I have to turn the better (for the time being at least)

lread20:08:02

Yeah, that would be what I'd do too. Make your git repo main branch represent what you want to actually release, then release, then merge your wip branch into your main branch.

lread20:08:00

If you get stuck again, come on back and we'll try to lend a hand.

lread20:08:51

My pleasure