librelist archives

« back to archive

Clarifications about :scope in dependencies

Clarifications about :scope in dependencies

From:
Julien Eluard
Date:
2014-09-07 @ 15:14
Hi,

I am not quite clear about the role of :scope in a dependency definition.
I've seen it used and use it myself but more in the hope it does something
than anything else.
Also I noticed it's been recently removed from sample.project.clj.

Can someone clarify its usage?

Thanks,
Julien

Re: [leiningen] Clarifications about :scope in dependencies

From:
Phil Hagelberg
Date:
2014-09-08 @ 04:22
Julien Eluard <julien.eluard@gmail.com> writes:

> I am not quite clear about the role of :scope in a dependency definition.
> I've seen it used and use it myself but more in the hope it does something
> than anything else.
> Also I noticed it's been recently removed from sample.project.clj.

It was removed because there shouldn't be any need to specify it.

Maven uses scope to indicate certain dependencies are test-only, or
"provided", which means they are visible at compile time but not
considered transitive dependencies because they are present in the
runtime container intended for deployment (usually Hadoop).

Leiningen uses profiles for this instead; there is the :dev profile and
the :provided profile. Dependencies from :dev are placed in the pom as
scope=test, but this does not affect downstream consumers and should
only be noticeable if you try to build the project with Maven instead of
Leiningen. Things from the :provided profile also have their scope set.

Before Leiningen had a :provided profile, you could set :scope in
individual :dependencies vectors, but these days you should never have
to set it.

-Phil

Re: [leiningen] Clarifications about :scope in dependencies

From:
Hugo Duncan
Date:
2014-09-08 @ 11:04
phil@hagelb.org writes:

> Before Leiningen had a :provided profile, you could set :scope in
> individual :dependencies vectors, but these days you should never have
> to set it.

I think :scope is still useful if you need to set a scope for a
dependency in a profile that is designed to be composed into a profile
other than :profile, eg. :downstream.  This is something of a corner
case, but I hope :scope continues to be supported.

Hugo

Re: [leiningen] Clarifications about :scope in dependencies

From:
Phil Hagelberg
Date:
2014-09-08 @ 16:01
Hugo Duncan <hugo@hugoduncan.org> writes:

> I think :scope is still useful if you need to set a scope for a
> dependency in a profile that is designed to be composed into a profile
> other than :profile, eg. :downstream.  This is something of a corner
> case, but I hope :scope continues to be supported.

Do you mean setting :scope "provided" in the :downstream profile? Given
that the point of the :downstream profile is to function like :provided
except that it also allows dependencies to be picked up transitively,
this seems contradictory. Can you explain a use case?

-Phil

Re: [leiningen] Clarifications about :scope in dependencies

From:
Julien Eluard
Date:
2014-09-08 @ 11:31
Thanks for the explanation it's much clearer now.

Julien


2014-09-08 1:22 GMT-03:00 Phil Hagelberg <phil@hagelb.org>:

> Julien Eluard <julien.eluard@gmail.com> writes:
>
> > I am not quite clear about the role of :scope in a dependency definition.
> > I've seen it used and use it myself but more in the hope it does
> something
> > than anything else.
> > Also I noticed it's been recently removed from sample.project.clj.
>
> It was removed because there shouldn't be any need to specify it.
>
> Maven uses scope to indicate certain dependencies are test-only, or
> "provided", which means they are visible at compile time but not
> considered transitive dependencies because they are present in the
> runtime container intended for deployment (usually Hadoop).
>
> Leiningen uses profiles for this instead; there is the :dev profile and
> the :provided profile. Dependencies from :dev are placed in the pom as
> scope=test, but this does not affect downstream consumers and should
> only be noticeable if you try to build the project with Maven instead of
> Leiningen. Things from the :provided profile also have their scope set.
>
> Before Leiningen had a :provided profile, you could set :scope in
> individual :dependencies vectors, but these days you should never have
> to set it.
>
> -Phil
>