Fork me on GitHub
#cljdoc
<
2021-03-17
>
Adam Helins16:03:57

I've written a CLJC lib which has a namespace with test.check generators. I don't want to force a dependency on test.check, this namespace is sort-of optional. Of course, Cljdoc cannot analyze this namespace since test.check is missing. Is there a solution, a way of declaring an optional dep for Cljdoc?

Adam Helins18:03:56

I might be mistaken but I don't think this solves the problem. Here, if I want to use that namespace, I just have to add test.check to my deps. If I don't want to use it, I simply don't require. The problem is that Cljdoc has no way of knowing that it needs test.check for analyzing that namespace and producing doc. It throws because test.check is not found.

localshred18:03:42

can you put the test.check dep in an alias and use that alias when generating cljdocs?

Adam Helins18:03:30

@localshred Yes that would be ideal but is it possible to specify an alias for Cljdoc? I didn't find anything in the doc, maybe an oversight

localshred18:03:02

ah, that I'm not aware of... sorry 😞

martinklepsch20:03:58

hey @adam678! if you specify a :scope "test" or :scope "provided" for the dependency it will be included during analysis but not considered a dependency by regular consumers

martinklepsch21:03:03

It is a common pattern for Java pom.xml files to include optional dependencies this way

Adam Helins21:03:09

@martinklepsch Thanks Martin! I am not sure, does deps support adding a scope?! The generated pom file simply adds the dependency as a regular dep

Adam Helins21:03:42

I found that thread which mention this exact problem (in the context of Cljdoc) but no solution: https://ask.clojure.org/index.php/9110/scope-in-deps-edn-should-be-added-and-not-deleted-from-pom-xml