Fork me on GitHub
#leiningen
<
2022-03-11
>
MIJOTHY10:03:02

I’m trying to extract classpaths from leiningen-built uberjars, and my current method is to use maven to unpack the pom.xml from within the META-INF folder of the uberjar and build the classpath from there. However, I’m running into an issue where the generated pom.xml doesn’t include all dependencies. With a project like

:dependencies [[my-org/project-A "1.0.0"]]
:profiles {:my-profile {:dependencies [[my-org/project-B "1.0.0"]]}}
:aliases {"my-uberjar" ["do" ["with-profiles" "my-profile" "uberjar"]] 
running lein my-uberjar creates an uberjar with a pom.xml in the respective META-INF directory that mentions project-A but not project-B. This is also visible when running lein pom and lein with-profiles my-profile pom. I don’t have a very deep understanding of either of these tools, so perhaps someone can let me know if some of my expectations are incorrect? • lein with-profiles <profile> pom creates a pom.xml with the specified profile’s configuration • lein with-profiles <profile> uberjar creates an uberjar according to the specified profiles, putting a pom.xml in the uberjar at META-INF/maven/<group-id>/<artifact-id>/pom.xml. This pom.xml is created by the same machinery as lein with-profiles <profile> pom, so should contain the specified profile’s configuration

MIJOTHY10:03:05

I should mention, this is mostly for my own edification at this point. There are other more direct ways of doing what I’m going for without needing to extract classpaths from jars.

MIJOTHY15:03:41

so apparently one issue is that i need the profile there to be marked ^:leaky (see https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md#profile-metadata) for its info to be included in the pom.xml . also in my actual setup there is an :aot in the my-profile profile that might be confounding things, which allows the uberjar to be built correctly with project-B but the pom to omit that dependency

mikerod03:03:54

We actually got to the bottom of this issue. I'll log a lein issue to give an example of an inconsistency with leaky profile behavior in the pom vs jar dependencies during uberjar or jar tasks. Coming soon.