Skip to content

A leiningen plugin that lets you share tools.deps.alpha dependencies in your leiningen project

License

Notifications You must be signed in to change notification settings

RickMoynihan/lein-tools-deps

Repository files navigation

lein-tools-deps

WARNING: This project is unmaintained and targets a 4y/old version of tools.deps

Clojars Project

Build Status

A leiningen plugin that lets you sharetools.deps.alpha deps.edndependencies with your leiningen project build.

Do you really want to use this?

Probably not, it has been over 4 years since its last update; and is hugely behind on changes in tools.deps. If you think you need to use this, then you should expect to fork it and maintain it going forward, or if you requiregit/deps usetools.build instead.

If you plan on forking this, then you will probably want to update to a more recent version of tools.deps, and I'd also suggest at least fixing this issueif you intend to also use it for library development.

lein-tools-depshas to square the circle between leiningen & maven's dependency resolution algorithm and that used by tools.deps. Leiningen and Maven, when there is a conflict always pick the version that is closest to the root of the dependency tree; where astools.depsalways picks the newest.

In order to square this circle,lein-tools-depsresolves all dependencies withtools.depsand flattens the tree before inserting it into lein's :dependenciesvector. This guarantees the resolution is the same as tools.depswould give; however it has the unfortunate effect of flattening your libraries dependencies for consumers of your library. This makes it significantly harder for consumers to use:exclusionsand overrides when they get a conflict on a transitive dependency brought in by your library.

Why use leiningen and deps.edn?

The Clojure 1.9.0 command line tools bring a host of new benefits to the Clojure practitioner. In particular native support for dependencies hosted in git repositories (and not deployed as maven artifacts), faster startup times for project REPLs, and easier ways to script with Clojure and define multi-project projects; all whilst providing a purely declarative data format in the form ofdeps.edn files.

However at its coredeps.ednand the CLI tools are just a simple system that provide better facilities for resolving dependencies and building a java classpath. They actively avoid being a build tool, and consequently can't be used in isolation to build a project,:aot compile it,uberjarit, etc...

Leiningen is the incumbent build tool for Clojure projects. It's well supported, with a thriving plugin ecosystem, and is the default choice in the Clojure world if you need to build an application or deploy a library. It's easy to get started with and is great if you have a pro-forma project; which doesn't need much custom build-scripting.

lein-tools-depsteaches Leiningen to take its:dependenciesfrom yourdeps.ednfiles, which means you can get the best of both worlds. You can usecljanddeps.ednto take advantage of deps.ednsub-projects, located on the local filesystem (:local/root) and in git repositories (:git/url) or make use of standard maven dependencies (:mvn/version).

lein-tools-depswill let you replace your leiningen:dependencies entirely with those fromdeps.ednmeaning you don't need to repeat yourself. Likewise fordeps.ednprojects if you need to start :aotcompiling,uberjaring, or integrating with a:cljs-build, you now can.

Essentiallylein-tools-depslets Clojure practitioners use both Leiningenand theclj/deps.edntools together in the same project.

Why not use boot instead?

Boot is arguably a better choice than Leiningen if you need more bespoke build scripting. However Leiningen projects because of their declarative constraints tend to be more uniform and familiar. Leiningen projects are harder to turn into unique snowflakes, which might be better or worse for you.

If you don't need anything fancy (like a combined Clojurescript/Clojure build) and want to just get started quickly, I'd recommend Leiningen over Boot. If you don't need to:aot,or to build your Clojure at all, and your development environment and prefered tools support it go lightweight and just usecljanddeps.edn.

If you want to integrate boot withtools.depsyou can via @seancorfield's boot-tools-deps.

Why not just use deps.edn?

If you can do this, consider it, and consider not usinglein-tools-depsat all. Yes, I'm saying maybe you don't need this project; even if it is pretty good:-)

deps.ednis starting to grow an ecosystem of tools and whilst they're not yet mature, and the landscape is frequently changing, with various contenders many existing tools such as the Clojurescript compiler, and figwheel-main have native support fordeps.edn.Additionally there are new tools such asdepstar, pack.alpha,katamari that will work withdeps.ednand might be able to build that uberjar for you.

See thetools.deps Toolspage for a more complete list of available tooling.

lein-tools-depsis for those who need or want to keep a foot in both camps. Perhaps it's suitable as a stop gap solution for an existing leiningen project, or perhaps members of your team are only just getting used to leiningen, and you don't want to confuse them with another tool or workflow.

Usage

Simply add the following to your plugins and middleware vectors, respectively, in yourproject.clj:

:plugins[[lein-tools-deps"0.4.5"]]
:middleware[lein-tools-deps.plugin/resolve-dependencies-with-deps-edn]

Then set:lein-tools-deps/configto specify whichdeps.ednfiles to resolve, we recommend:

:lein-tools-deps/config {:config-files [:install:user:project]}

The keywords:install,:userand:projectwill be resolved by the plugin. You can also supply your own paths as strings, e.g.

:lein-tools-deps/config {:config-files [:install:user:project "../src/deps.edn" ]}

You can now delete your:dependenciesvector fromproject.clj.

Note: Withlein-tools-deps0.3.0-SNAPSHOTand earlier, the config value was a vector and looked like:tools/deps [:install:user:project],as of 0.4.0 it changed to the above map based syntax.

Supported configuration options

:config-files

A vector referencing an ordered collection ofdeps.ednfiles that will be used for dependency resolution. Each file should be either a file path string or a special keyword (:install:useror :project). The special:installand:userkeys refer to thedeps.edn files defined in the installation and user's home.clojureconfig directories; whilst:projectrefers to adeps.ednat the root of your leiningen project.

:clojure-executables

A vector of strings identifying possible install locations for the clojurecommand line tool script. They will be tried in order, with the first match being used. The default is currently set to [/usr/local/bin/clojure].This is necessary aslein-tools-deps uses theclojureexecutable to determine some system specific defaults, such as the location of the:install:config-files.

:resolve-aliases

A vector ofdeps.ednalias names whose:extra-deps,override-deps and:default-depswill be resolved with the same semantics as if they had been used with the-Roption to thecljtool.

:classpath-aliases

A vector ofdeps.ednalias names whose:extra-pathsand classpath-overrideswill be applied with the same semantics as if they had been used with the-Coption to thecljtool.

:aliases

A vector ofdeps.ednalias names whose values are resolved in the same way as for both:resolve-aliasesandclasspath-aliasesabove. Equivalent to the-Aoption of thecljtool.

Profiles

lein-tools-depsworks with Leiningen profiles, allowing you to specify dependencies on a per profile basis. We support the use of any configuration options in Leiningen profiles, which will follow Leiningen's standard meta-mergesemantics for each of the configuration options above. Profiles are merged beforetools.depsresolution.

E.g.

:lein-tools-deps/config{:config-files["foo.edn"]}
:profiles{:dev{:lein-tools-deps/config["bar.edn""baz.edn"]}}

results a logical:config-filesvalue of[ "foo.edn" "bar.edn" "baz.edn" ]when the:devprofile is used.

Aliases and all other options are resolved in a similar fashion, and support the use of Leiningen's^:replace/^:displacemetadata flags, to control the merge.

One of the benefits oflein-tools-depsis that you can use profiles to group various combinations of:aliasesetc under a single profile name.

Prerequisites

You will need the following base dependencies installed:

Project Status

ALPHAbecausetools.depsis still.alpha.

PRs & ideas for future development welcome.

Please see theissue tracker

With thanks to

  • @HughPowell
  • @mfikes
  • @seancorfield
  • @puredanger
  • @atroche
  • @marco-m

License

Copyright © 2017 Rick Moynihan

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

A leiningen plugin that lets you share tools.deps.alpha dependencies in your leiningen project

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published