Coder Social home page Coder Social logo

lein-parent's Introduction

lein-parent

A Leiningen plugin for inheriting properties from a parent project.

This plugin is useful when you have a series of related projects that all share some set of properties and want to avoid duplicating the values across projects. e.g. you have several projects that all share the same Maven private repository information.

lein-parent is the conceptual reverse of lein-sub.

Usage

Put [lein-parent "0.3.3"] into the :plugins vector of your project.clj.

Specify a parent in your project.clj and which properties to inherit from it as follows.

:parent-project {:path "../project.clj"
                 :inherit [:dependencies :repositories [:profiles :dev]]
                 :only-deps [org.clojure/clojure com.stuartsierra/component]}

As of lein-parent 0.3.0 and leiningen 2.7.0, you can also reference a parent project by its lein/maven coords, like this:

:parent-project {:coords [org.foo/clojure-parent-project "1.0.0"]
                 :inherit [:managed-dependencies]}

Inherited properties may be either keywords or sequences of keywords. These values are used to select which properties from your parent to merge into your project. To select only specific dependencies, specify the first part of the dependency atoms in a sequence with :only-deps. To see the actual values of these properties, run:

$ lein parent

Managed Dependencies

Leiningen 2.7.0 introduced support for a :managed-dependencies property in your leiningen project file. Using this property, you can define version numbers in the :managed-dependencies section without causing the dependencies to be realized / enforced. Then, you can omit the version number from the :dependencies section and just specify the dependency group id / artifact id. This will cause the dependency to be realized, and the version will be inherited from the :managed-dependencies section.

When combined with lein-parent, this allows you to :inherit the :managed-dependencies section from a parent project and share the version numbers for common dependencies across many child projects. This can be very powerful in reducing the burden of dealing with transitive dependency version conflicts across multiple projects.

For example:

(defproject superfun/myparent "1.0.0"
   :managed-dependencies [[clj-time "0.12.0"]
                            [me.raynes/fs "1.4.6"]
                            [ring/ring-codec "1.0.1"]])

(defproject superfun/kid-a "1.0.0-SNAPSHOT"
   :parent-project {:coords [superfun/myparent "1.0.0"]
                    :inherit [:managed-dependencies]}
   :dependencies [[clj-time]
                  [me.raynes/fs]])

(defproject superfun/kid-b "1.0.0-SNAPSHOT"
 :parent-project {:coords [superfun/myparent "1.0.0"]
                  :inherit [:managed-dependencies]}
 :dependencies [[clj-time]
                [ring/ring-codec]])

For more information, see leiningen's docs on Managed Dependencies

License

Copyright © 2014 Alex Chin

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

lein-parent's People

Contributors

achin avatar aletts avatar bbbates avatar cprice404 avatar libbymo avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.