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

Inter-Project Dependencies

Manage dependencies between subprojects and ensure correct build order and artifact resolution.

Introduction to Project Dependencies

In a multi-project Gradle build, different subprojects often need to work together. One subproject might produce a library that another subproject uses.

This is where inter-project dependencies come in! They define how subprojects rely on each other, ensuring the correct build order and artifact sharing.

  • Inter-project dependencies: How one subproject uses code or outputs from another subproject.
  • Crucial for modular applications.

Declaring a Basic Dependency

Declaring that one subproject depends on another is straightforward in Gradle. You use the project() function within your dependencies block.

For example, if your app subproject needs code from your lib subproject, you'd add this to app/build.gradle:

// app/build.gradle
dependencies {
    implementation project(':lib')
}

The :lib part refers to the path of the lib subproject relative to the root.

All lessons in this course

  1. Monorepo Project Structure
  2. Subprojects & Configurations
  3. Inter-Project Dependencies
  4. Composite Builds and Build Composition
← Back to Groovy & Gradle: JVM Automation and Build Engineering