EwenG / badigeon

A Clojure build library based on tools.deps.
144 stars 19 forks source link

Additional POM elements? #10

Closed favila closed 5 years ago

favila commented 5 years ago

Is there any way to inject additional pom metadata elements into the generated pom when using jar? I'm trying to generate a maven-central compatible POM; they require some additional elements, e.g.: name description license url scm, developers, etc (see reference)

Clojars understands and uses some of these fields also. e.g. it can link to websites or github repositories in their web interface if url and/or scm is supplied.

Thanks for this wonderful lib; it's the only thing I've found that can properly package library (not app!) jars for deps.edn-based projects.

EwenG commented 5 years ago

You can directly add them to the pom.xml file. Badigeon will synchronize things like the artifact-id, group-id, version ... but it will not change other entries in the pom.xml file.

I should probably document it somewhere.

Let me know if that fit your needs.

favila commented 5 years ago

Oh, I didn't catch that jar/jar used sync-pom instead of overwriting the pom. Yes, this solution is fine; I guess I'm just used to the leinigen way where the entire pom is purely a derived/generated artifact, not a synced one. I was looking for some argument to jar that would allow injection.

I still prefer either the lein way (pom data's source of truth is somewhere in Clojure or build scripts) or a way to merge a "slim" base pom with the injected portions added during build (although I can emulate this myself by copying e.g. 'base-pom.xml' to pom.xml before calling jar). The reason is I want to treat the pom as an uncommitted build artifact, not something I commit after every deps or version change. (I'm also not committing version numbers but basing them off git tags, but that complexity is on me.) Also in general I prefer an entity (e.g. file, data structure) to be either primary or derived not a mix of both. Consider this a low priority feature request because it's certainly possible for me to do this on my own.

Thanks for you help!

EwenG commented 5 years ago

You could generate the pom.xml file using clojure.data.xml, just like sync-pom does:

(xml/alias-uri 'pom "http://maven.apache.org/POM/4.0.0")

(spit
 "pom.xml"
 (xml/indent-str
  (xml/sexp-as-element
   [::pom/project
    {:xmlns "http://maven.apache.org/POM/4.0.0"
     (keyword "xmlns:xsi") "http://www.w3.org/2001/XMLSchema-instance"
     (keyword "xsi:schemaLocation") "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"}
    [::pom/description "Lib description"]])))