Fork me on GitHub

A heads up for folks using either depstar or with Polylith for building library JAR files: external deps from bricks will not show up in the generated pom.xml that ends up in the JAR file, only the deps from the project itself. I'm working on some stuff for Polylith so I'll have a better story for this soon... how many folks are building deployable libraries from Polylith projects, as opposed to application uberjars?


We aren't yet but once we finish migration we will need to


Hopefully, I'll have a nice, generic solution by then 🙂

👏 3
🙏 2

Thank you for spending time on this!


io.github.seancorfield/build-clj {:git/tag "v0.5.1" :git/sha "dc121d6"} addresses this by adding a :transitive true option to the jar task.

🙌 1
metal 2

@U04V70XH6 We’re deploying a library to S3 from Polylith using and slipset/deps-deploy. The only irritating thing so far has been that we’ve had to add our component dependency list to build.clj (`:src-dirs`) rather than the deps.edn located in the project directory.


(That could be ignorance on my part, though.)


@U0HJA5ZQT If you use my build-clj wrapper for, you will have a simpler build.clj file and you can just pass :transitive true to the jar task (in build-clj).


How are you building your pom.xml for the library?


That's something else gets "wrong" by default for Polylith-based libraries.



(defn jar [_]
  (println "Writing pom.xml")
  (b/write-pom {:class-dir class-dir
                :lib       lib
                :version   version
                :basis     basis
                :src-dirs  src-dirs})
  (println "Copying src dirs")
  (b/copy-dir {:src-dirs   src-dirs
               :target-dir class-dir})
  (println "Creating the jar")
  (b/jar {:class-dir class-dir
          :jar-file  jar-file})


How are you computing that basis? Do your libraries have external dependencies declared in the components's deps.edn files?


The issue I raised is that by default the pom.xml generated that way will not have the top-level library dependencies from the components -- only the top-level library dependencies from the projects... But you should not need to specify library dependencies in projects's deps.edn if the components's deps.edn files already contain those (unless you are deliberately overriding them with different versions).


And you're having to maintain that list of src-dirs yourself, right? My wrapper with the :transitive true option takes care of that automatically for you: it figures out the sources to include, based on the dependencies in the projects's deps.edn file.


Mmm, gotcha. Yeah, I’m including them in the project deps.


Right, so you're duplicating a bunch of stuff and having to maintain that manually. You don't need to.


For us, that's all automatic now.


Okay, I gotcha. Cool! Yeah, I hadn’t looked at that in a bit, and you’re right—I must have duplicated it to include the deps.


But will that resolve this?


(def src-dirs ["../../components/utils-cast/src"


I’m actually confused by’s use of src-dirs: it appears to only include one in the POM, but needs the rest for the JAR. I’d prefer I not even need these references, even in the project’s deps.edn.


For write-pom, you should just use the projects source dir (if any).


But the basis for write-pom needs the top-level transitive deps from the components (in addition to the project) -- but you shouldn't need to duplicate any library deps and they should be in the components, if the components rely on a library (other components do not belong in components deps.edn files, just libraries).


If you use build-clj, your entire jar task would become (bb/jar {:lib lib :version version :transitive true}) followed by your call to (record-versions)


(that's not a Polylith project but :transitive true would be the only difference)


Here's Polylith's build.clj (on the shell branch): -- showing how it builds libraries.


(it only copies the pom.xml out because it wants to delete the classes folder so things are cleaned up during the build -- to match the legacy deployer behavior)


@U04V70XH6 That is all super helpful. I’m looking forward to more of the community adopting—the docs are so slim!