18

I've seen a lot of places where some dependencies in Clojure project are marked with :scope "provided" (example).

What does it mean?

OlegTheCat
  • 4,443
  • 16
  • 24
  • 2
    you can read about maven scopes, since it is the same thing. http://stackoverflow.com/questions/6646959/difference-between-maven-scope-compile-and-provided-for-jar-packaging so as far as i can understand, if you use this lib in your project, you should also add these dependencies to your project.clj, together with the lib itself (still i can be mistaken) – leetwinski Sep 07 '16 at 14:34
  • there is also some other scopes you can use: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope – leetwinski Sep 07 '16 at 14:39
  • @leetwinski thanks, it seems to be clear now. BTW, is there any reason to use `:scope "test"` instead of `:test` profile? – OlegTheCat Sep 07 '16 at 14:55
  • 1
    the reason here is also to prevent a transitive dependcy into specific versions (of e.g. clojure). it's used here in that manor, because the library author does not want to pollute the projects of the users of the lib. – cfrick Sep 07 '16 at 14:59
  • I've read the answers to the questions like the one linked by @leetwinski, and I still don't feel very comfortable with making decisions about what scope to use for my dependencies, especially when I'm using [Boot](http://boot-clj.com/). If someone posts a good answer to this question that speaks specifically to Clojure and talks about what to do for different types of projects, I'll give it a bounty. – Sam Estep Sep 07 '16 at 19:22
  • There is no single answer, there are an infinite variety of projects. But the key is that build and development time are different from deployment and run time. This distinction is where scopes matter. A dependency in scope "provided" just means that the application will be running in an environment, like an application server container, that itself includes- or "provides"- the dependency, so packaging tooling knows that the dependency should not be packaged with the application. – Jonah Benton Sep 08 '16 at 02:42
  • @leetwinski you may drop an answer with link to maven doc and I'll accept it - the original question seems to answered for me – OlegTheCat Sep 09 '16 at 08:46
  • for further investigation we may create more specific questions @SamEstep – OlegTheCat Sep 09 '16 at 08:47
  • @OlegTheCat done. By the way (offtopic): if you are "the cat" why do you have a bird on your avatar? It just blows my mind every time i see it )) – leetwinski Sep 09 '16 at 14:40
  • @leetwinski oh... that's just historical :) – OlegTheCat Sep 09 '16 at 19:32

2 Answers2

11

This is essentially a maven concept. Provided means that the given dependency is already packaged(or "provided" if you will) with the environment. The jar is necessary for compiling but it won't be packaged with the app. Also these are not transitive dependencies.

To understand more about transitive dependency refer here.

Abhiroop Sarkar
  • 2,251
  • 1
  • 26
  • 45
5

You can read about maven scopes, since it is the same thing. Difference between maven scope compile and provided for JAR packaging . So as far as i can understand, if you use this lib in your project, you should also add these dependencies to your project.clj, together with the lib itself (still i can be mistaken)

There are also some other scopes you can use: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

Community
  • 1
  • 1
leetwinski
  • 17,408
  • 2
  • 18
  • 42