0Pricing
Groovy & Gradle: JVM Automation and Build Engineering · Lesson

Declaring Project Dependencies

Learn various ways to declare dependencies in `build.gradle` for different scopes and types.

Project Needs & Dependencies

Modern software projects rarely work in isolation. They often rely on external code, known as dependencies, to perform various tasks.

Think of dependencies as pre-built tools or libraries that save you from writing common functionalities from scratch, like logging, parsing JSON, or connecting to a database.

  • Libraries: Collections of code (e.g., Apache Commons).
  • Frameworks: Structured foundations for applications (e.g., Spring Boot).
  • Modules: Components of a larger system.

Gradle's `dependencies` Block

In Gradle, you declare all your project's dependencies within a dedicated dependencies { ... } block in your build.gradle file.

This block is central to managing what your project needs to compile, test, and run.

/* build.gradle */

plugins {
  id 'java'
}

repositories {
  mavenCentral()
}

dependencies {
  // Your dependencies go here!
}

All lessons in this course

  1. Declaring Project Dependencies
  2. Dependency Resolution & Caching
  3. Custom Repositories & BOMs
  4. Resolving Version Conflicts & Dependency Constraints
← Back to Groovy & Gradle: JVM Automation and Build Engineering