Defining dependencies

We discussed how to use dependency configurations to group together dependencies; we also saw how we must define repositories so that the dependencies can be resolved, but we haven't discussed how to define the actual dependencies yet. We define dependencies in our build project with the dependencies{} script block. We define a closure to pass to the dependencies{} script block with the configuration of the dependency.

We can define different types of dependencies. The following table shows the types that we can use:

Dependency type

Method

Description

External module dependency

-

This is a dependency on an external module or library in a repository.

Project dependency

project()

This is a dependency on another Gradle ...

Get Gradle Effective Implementations Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.