leiningen

Abhinav 2024-09-16T16:42:45.081089Z

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

ghaskins 2024-09-17T12:44:03.323919Z

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
ghaskins 2024-09-17T12:45:37.112479Z

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"

ghaskins 2024-09-17T12:46:46.757119Z

apologies: its “artifact” not “asset”

ghaskins 2024-09-17T12:46:48.151339Z

https://maven.apache.org/repositories/artifacts.html

ghaskins 2024-09-17T12:53:36.119709Z

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
seancorfield 2024-09-17T17:42:04.222229Z

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?

seancorfield 2024-09-16T16:57:34.541649Z

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

Abhinav 2024-09-17T05:43:54.286939Z

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

Abhinav 2024-09-23T04:26:05.495859Z

> 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.

seancorfield 2024-09-23T04:44:12.082329Z

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.

seancorfield 2024-09-23T04:44:45.950669Z

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

Abhinav 2024-09-23T04:52:37.840929Z

> 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 🙂

seancorfield 2024-09-23T04:53:45.793659Z

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.

seancorfield 2024-09-23T04:54:59.000149Z

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

seancorfield 2024-09-23T05:27:10.386959Z

> 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?

seancorfield 2024-09-23T05:29:34.316049Z

(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)