What does :scope "provided" mean?
Asked Answered
H

2

18

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

What does it mean?

Heinrick answered 7/9, 2016 at 14:29 Comment(10)
you can read about maven scopes, since it is the same thing. #6647459 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)Jerriejerrilee
there is also some other scopes you can use: maven.apache.org/guides/introduction/…Jerriejerrilee
@Jerriejerrilee thanks, it seems to be clear now. BTW, is there any reason to use :scope "test" instead of :test profile?Heinrick
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.Aerogram
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. 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.Valuate
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.Burnet
@Jerriejerrilee you may drop an answer with link to maven doc and I'll accept it - the original question seems to answered for meHeinrick
for further investigation we may create more specific questions @SamEstepHeinrick
@Heinrick 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 ))Jerriejerrilee
@Jerriejerrilee oh... that's just historical :)Heinrick
J
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

Jerriejerrilee answered 9/9, 2016 at 14:37 Comment(0)
R
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.

Rakia answered 9/9, 2016 at 11:29 Comment(0)
J
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

Jerriejerrilee answered 9/9, 2016 at 14:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.