Welcome! Please see the About page for a little more info on how this works.

+13 votes
in tools.deps.alpha by

When adding a dependency, I'd like to be able to specify aliases in coordinates of libraries that use deps.edn, for example:

{:deps {org.clojure/clojure {:mvn/version "1.10.0"}
        org.openjfx/javafx-base {:mvn/version "12-ea+10"}}
 :aliases {:web {:extra-deps {org.openjfx/javafx-web {:mvn/version "12-ea+10"}}
                 :extra-paths ["src/web"]}
           :controls {:extra-deps {org.openjfx/javafx-controls {:mvn/version "12-ea+10"}}
                      :extra-paths ["src/controls"]}}
 :paths ["src/base"]}

use:

{:deps {git/lib {:git/url "..." 
                 :sha "..."
                 :aliases ["controls"]}}}

This way it will be possible to make more fine-grained libraries that may have optional code/dependencies which won't bloat classpath when unneeded.

4 Answers

0 votes
by

Comment made by: borkdude

Interestingly, I think this also implements a feature that some people have been asking for, namely managed dependencies.

libs/deps.edn could be an empty project that only describes groups of dependencies via aliases (managed deps).
app/deps.edn can consume these groups like in the above example.

Minor detail: maybe :aliases should contain keywords instead of strings?

0 votes
by
Reference: https://clojure.atlassian.net/browse/TDEPS-116 (reported by alex+import)
0 votes
by

Yes please! Being able to use an alias, or aliases, in a git dependency offers the opportunity to stitch together different facets of a single project. A single project may contain aliases for different architectural levels such as a core library, or a server implementation etc. Clients of that project could then choose to use those different facets as required. The current alternative is to use multiple git repositories.

0 votes
by

We have a specific use-case for this at Metabase and it's one of the things that's making it hard for us to transition to deps.edn. Here's a simplified version of the problem we're facing:

At Metabase we ship both an FOSS edition (under the AGPL) and an Enterprise Edition under a commercial license. We can't ship the Oracle JDBC driver in the FOSS edition because the license terms of the JDBC driver make it AGPL-incompatible. However, we can ship it with the EE version.

The Oracle driver is itself a subproject in the larger Metabase-core repo.
We want to be able to have a top-level :ee alias that merges in the :ee aliases from the :local/root stuff it pulls in. Example:

;; ./deps.edn
{:deps
 {:local/root "oracle-driver"}
 :aliases 
 {:ee
  {:extra-deps {:local/root "oracle-driver", :alias :ee}}}}

;; oracle-driver/deps.edn
{:aliases
 {:ee
  {:extra-deps
   {com.oracle.ojdbc/ojdbc8 {:mvn/version "19.3.0.0"}}}}}
...