leiningen 2024-09-16

Hi, I have a library on clojars. I want to create two "variants" of it with two different dependencies and deploy them separately to clojars. What's the best way to do this? Thanks

As far as I know, clojars follows the “GAV” (group, asset, version) coordinate model from Maven, so I think the only way to represent two “variants” is to give them distinct GAV coordinates

👀 1

based on the limited info I have about what you want to do, it seems the most natural would be to alter the asset with additional variant info, e.g. “$asset-variant1” and “$asset-variant2"

apologies: its “artifact” not “asset”

I’ve never used this, but you may be able to exploit the “classifier” property of the GAV coordinate, rather than split the artifactid namespace

👀 1

You'll probably end up having to use mvn directly to do this as I do not believe classifiers are well-supported by Clojure tooling (for publishing, they are supported for consuming but perhaps not well-documented). I guess I'd take a step back and ask: why do you want to publish two variants? What are the behaviors that are affected by the dependencies?

Uberjars? Those are applications. It's unusual to deploy applications to Clojars -- it's for libraries.

Oh, my bad, I have a library and I want to deploy it to clojars. Edited the description 😓

> why do you want to publish two variants? My library is a cljc library. And it depends on clojurescript because it uses the analyzer. however, the clojurescript isn't required if the user is only using it for clojure, and have cljs as a dependency can sometimes pull in other dependencies which can cause incompatibilities with libraries used in a clojure project. Hence, I thought I should bundle them into two different projects, one purely clj and one cljc. It is also possible that I wasn't excluding the correct transitive dependency and this is the real problem, not the fact that the project pulls in cljs.

If you have a .cljc project, it's generally up to your users to have a dependency on ClojureScript if they're using... ClojureScript. That's my thinking on it.

HoneySQL is (nearly) all .cljc and needs ClojureScripts for testing but does not include a dependency on cljs directly.

> If you have a .cljc project, it's generally up to your users to have a dependency on ClojureScript if they're using... ClojureScript. That's my thinking on it. I see, let me try excluding cljs as a dep and see if I can get it to work. thanks for the ideas 🙂

Well, you only need the cljs dep in your project for dev/test. Your users don't need that dep if they're Clojure (JVM) only. That's the way to look at it.

Look at https://github.com/seancorfield/honeysql/blob/develop/deps.edn for example. ClojureScript is needed for testing, but that's it.

> it depends on clojurescript because it uses the analyzer That can all be handled by reader conditionals -- so it only uses the analyzer for cljs and whenever your library is used by cljs projects, they'll already have cljs as a dependency -- so that dependency shouldn't be a problem?

(I just realized I linked you to a deps.edn project -- and I see this thread is in #leiningen -- but the same principle applies, but with profiles in lein instead of aliases; I haven't used Leiningen since 2015)