Two different versions of the same library for two different Clojure versions.

60 views
Skip to first unread message

Manoj Waikar

unread,
Mar 19, 2012, 1:46:49 AM3/19/12
to clo...@googlegroups.com
Hi,

What if an author wants to maintain two versions of a library for two different Clojure versions? Assuming the functionality is the same in both the branches (one for say, Clojure 1.3 and the other for Clojure 1.2.1), both the branches might be at the same version, so how should he push the jar for such a library in Clojars (so that the library could be downloadable for any Clojure version)?

BTW, what is the general / good practice for versioning such a lib (which supports two different Clojure versions)?

Thanks,
Manoj.

Alex Osborne

unread,
Mar 20, 2012, 6:32:55 PM3/20/12
to clo...@googlegroups.com
Hi Manoj,

As far as I'm aware there's no way in the tools (Lein, Maven etc) to
specify different jars per Clojure version automatically.

Myself I'd try to make the one jar work for both. As a worst case you
might be able to include two different clj files in the one jar and load
them conditionally:

(ns mylib.core)
(if (too-old? *clojure-version*)
(load "mylib/legacy.clj")
(load "mylib/current.clj"))

If that's really not possible (for example if you need to AOT compile),
you could upload them with different version numbers eg: mylib 1.4 and
mylib 1.4-clj1.2.

Unless someone has any better ideas?

Cheers,

Alex

Alexander Yakushev

unread,
Mar 27, 2012, 5:41:52 PM3/27/12
to clo...@googlegroups.com
Looks like the latest Leiningen (2.0.0) supports this with profiles. It is still beta but you should probably take a look.

Nelson Morris

unread,
Mar 29, 2012, 10:06:25 PM3/29/12
to clo...@googlegroups.com
The classifier tag should be able to be used for this. I've seen it
differentiate jdk1.4 from later versions[1]. Unfortunately support
for this is lacking in the clojure ecosystem.

### support details below

lein 1.x and 2.0.0-preview2 should correctly pull dependencies with a
:classifier tag.

lein 1.x pom generation always uses nil as the classifier. lein
2.0.0-preview2 will let you specify profiles which could contain
different clojure versions and a :classifier tag. However, the pom
task does not export the :dependencies/:classifier correctly based on
profile settings. I'm working on this now and plan to have this fixed
in preview3.

It looks like clojars always uses nil for the classifier when adding
the jar[2]. This will probably need to be fixed as part of issue #35
[3]. Other repositories might work.

[1] http://search.maven.org/#search|ga|38|l%3A%22jdk14%22
[2] https://github.com/ato/clojars-web/blob/master/src/clojars/maven.clj#L89
[3] https://github.com/ato/clojars-web/issues/35

Reply all
Reply to author
Forward
0 new messages