poly
Search…
Libraries
Libraries are specified in deps.edn in each component, base, and project:
Entity
Scope
Location
Components
src
components/COMPONENT-DIR > deps.edn > :deps
test
components/COMPONENT-DIR > deps.edn > :aliases > :test > :extra-deps
Bases
src
bases/BASE-DIR > deps.edn > :deps
test
bases/BASE-DIR > deps.edn > :aliases > :test > :extra-deps
Dev project
src
./deps.edn > :aliases > :dev > :extra-deps
test
./deps.edn > :aliases > :test > :extra-deps
Other projects
src
projects/PROJECT-DIR > deps.edn > :deps
test
projects/PROJECT-DIR > deps.edn > :aliases > :test > :extra-deps
The poly tool parses each deps.edn file and looks for library dependencies, which are then used by the libs and test commands.
To list all libraries used in the workspace, execute the libs command:
1
poly libs
Copied!
An x means that the library is added to the src context, while t means that it's only used from the test context.
Libraries can be specified in three different ways in tools.deps:
Type
Description
Maven
As a Maven dependency. Example: clj-time/clj-time {:mvn/version "0.15.2"} where the key is the Maven groupId/artifactId. Those dependencies are stored locally in the ~/.m2/repositories directory (but can be changed in ~/.polylith/config.edn, property m2-dir).
Local
As a local dependency. Example: clj-time {:local/root "/local-libs/clj-time-0.15.2.jar"} where the key is an arbitrary identifier. A local dependency is a path to a locally stored file.
Git
As a Git dependency. Example: clj-time/clj-time {:git/url "https://github.com/clj-time/clj-time.git", :sha "d9ed4e46c6b42271af69daa1d07a6da2df455fab"} where the key must match the path for the library in ~/.gitlibs/libs (to be able to calculate the KB column).
The KB column shows the size of each library in kilobytes. If you get the key path wrong or if the library hasn't been downloaded yet, then it will appear as -. One way to solve this is to force dependencies to be downloaded by executing something like this from the workspace root:
1
clojure -A:dev:test -P
Copied!
In the tools.deps CLI tool, when a dependency is included using :local/root, only :src dependencies will be inherited while the :test dependencies will be ignored. The poly tool builds upon tools.deps but has its own test runner that is accessed via the test command. A difference between tools.deps CLI and the poly tool is that it also inherits dependencies from the test context. If you want to run the tests directly from a project using the tools.deps CLI tool, then you also have to add the test dependencies again in the project's deps.edn file under :aliases > :test > :extra-paths. As long as you run the tests with the built-in test command you don't have to worry about this.
Brick libraries
The brick columns are marked with an x if the library is used by the src code and with a t if it's only used by the test code.
Project libraries
The project columns are marked with an x if the library is used by the src code and with a t if it's only used by the test code.
The dependencies for a project are the sum of all dependencies that are indirectly included via its bricks, together with dependencies declared by the project itself. If different versions of the same dependency exist, then the latest version will be used for the project. An exception is if a dependency is overridden with override-deps in a project's deps.edn file, e.g.:
1
{...
2
:deps {poly/article {:local/root "../../components/article"}
3
poly/comment {:local/root "../../components/comment"}
4
poly/database {:local/root "../../components/database"}
5
...
6
7
:override-deps {clj-time/clj-time {:mvn/version "0.15.1"}}
8
...
9
}
Copied!
If we now run the libs command:
...we will have two versions of clj-time where the rb project uses "0.15.1" and the user component uses "0.15.2".
Here are all the places where libraries can be overridden:
Entity
Scope
Location
Dev project
src
./deps.edn > :aliases > :dev > :override-deps
test
./deps.edn > :aliases > :test > :override-deps
Other projects
src
projects/PROJECT-DIR > deps.edn > :override-deps
test
projects/PROJECT-DIR > deps.edn > :aliases > :test > :override-deps
If a library is overridden in the src scope it will also affect the test scope. If a library is overridden in the test scope it will only affect the test scope.
Compact view
If we have a lot of libraries, we can choose a more compact format by setting :compact-views to #{"libs"} in ./deps.edn or by passing in :compact:
Last modified 1mo ago
Copy link