How can I skip retrieving dependencies in the provided scope when retrieveManaged is true?

It seems like sbt is always fetching all dependencies while I install retrieveManaged := true

in build.sbt

.

I have multiple dependencies set up like provided

and I don't need them to be loaded into a directory lib_managed/

.

How do you tell sbt about it?

+3


source to share


2 answers


After a few days of searching, I found an sbt plugin that suits my requirement perfectly. https://github.com/xerial/sbt-pack .



While it's not about lib_managed, it fetches all dependencies in target / pack / lib without the ones provided. And target / pack can be distributed directly without useless cans. This is exactly what I need.

+4


source


The purpose of the module configuration provided

:

This is similar to compilation, but indicates that you expect the JDK or container to provide a runtime dependency. For example, when building a web application for Java Enterprise Edition, you must set a dependency on the Servlet API and its associated Java EE APIs for scope because the web container exposes these classes. This scope is only available on the compile and test path and is not transitive.

From the Maven docs (SBT uses Ivy, which in this case reuses Maven conventions).


The goal retrieveManaged := true

is as follows:



isolate your assemblies from flush ivy cache

From SBT Frequently Asked Questions


As such, I would say that it makes sense that dependencies provided

are still persisted down to lib_managed

under retrieveManaged := true

.

You might want to look at sbt-assembly as a way to bundle your application (including relationships provided

) instead of using retrieveManaged

.

+1


source







All Articles