Open lread opened 1 year ago
Always use pom.xml
in the jar if it exists.
This covers the typical use case.
When pom.xml
is not in jar:
Fall back to pom.xml
in project root.
Log that we are doing this.
Force user to specify path to pom.xml
.
Technically a breaking option.
I believe it boils down to the fact that I used existing capabilities in the analyzer, and there was (is?) no support for reading the pom file from the jar. This https://github.com/cljdoc/cljdoc-analyzer/blob/f10878e83ca85f758faf21ee5555524394edbac7/src/cljdoc_analyzer/runner.clj#L174 is where cljdoc tries to read the POM.
If we want the analyzer to be able to use the pom in the jar, then we could perhaps change the line to st. like
- pom-str (slurp pompath)
+ pom-str (or (slurp pompath) (slurp (str jar-contents-dir "/" pompath))) ; does this break on windows?
Update: Oh, I see it is a little more complicated, since the pom in the jar is at META-INF/maven/
Thanks for looking into this @holyjak.
If updating the cljdoc-analyzer itself would help, we can do that.
Ok @holyjak, I've poked around and thought it over.
We want the check action to mimic cljdoc prod. Cldjoc prod currently always uses the deployed pom outside the jar.
It is unlikely that pom.xml bundled in a jar would be different from a deployed pom.
It is legal for a jar to not contain a pom. A small minority of folks, for whatever reason, strongly prefer this. And cljdoc current supports this use case.
When using tools.build, the generated pom.xml is currently readily available on the file system.
To me, it looks like we have ease-of-use competing with replicating cljdoc production.
So... how about this?
When cljdoc-analyzer is run as a tool the analyze-local
command will:
./pom.xml
, this will trip up too many people who now use this file as a template for their generated pom. Technically a breaking change but given point 2 above, probably not one that folks will notice.pompath
argument
/META-INF/maven/$group-id/$artifact-id/pom.xml
we'll log that we are using that, else we will fail with a clear message. (We'll match any path dirs for $group-id
and $artifact-id
and assume they are correct).jarpath
argument
./target
, but different from today, fail with a clear error message if there is more than one match.Seem good?
It does!
On Slack, @hlship was wondering why the check action doesn't use the
pom.xml
within the built jar.The cljdoc analyzer, when used as a clojure tool, seems to want the
pom.xml
to also exist in the current dir:Maybe because technically the jar does not have to contain the pom? But 99% of folks do bundle it in.
Also, these days, a
pom.xml
, if it exists in a project root, is often a template for the generatedpom.xml
. So it would not be appropriate.