Kotlin Academy · Lesson

Dependencies and Plugins

Configure the build.

Lesson 2 of 413 steps

Dependencies and Plugins is a free Kotlin Academy lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Academy learning path, and your progress syncs across the web and the CoddyKit app. The Kotlin Academy course includes 4 lessons in total.

Dependency Configurations

Gradle groups dependencies by configuration, which controls when and where they are available:

  • implementation — compile and runtime, not exposed to consumers
  • api — also exposed to consumers
  • testImplementation — only for tests

implementation vs api

implementation hides a dependency from modules that depend on yours, improving build performance and encapsulation. Use api only when the dependency appears in your public types.

dependencies {
    api("com.squareup.okio:okio:3.9.0")          // leaks into public API
    implementation("com.google.code.gson:gson:2.11.0") // internal only
}

compileOnly and runtimeOnly

Some dependencies are needed at only one phase:

  • compileOnly — present at compile time, not packaged (e.g. annotations)
  • runtimeOnly — present at runtime only (e.g. a JDBC driver)
dependencies {
    compileOnly("org.projectlombok:lombok:1.18.32")
    runtimeOnly("org.postgresql:postgresql:42.7.3")
}

Dependency Coordinates

A coordinate is group:name:version. You can split it explicitly for clarity.

dependencies {
    implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.8.1")
}

Project Dependencies

In a multi-module build, one module depends on another with project(...).

dependencies {
    implementation(project(":core"))
}

Applying Core Plugins

Built-in plugins need no version. Community plugins are applied with an id and version.

plugins {
    id("java-library")
    kotlin("jvm") version "2.0.0"
    id("com.github.johnrengelman.shadow") version "8.1.1"
}

Plugins from the Portal

Most plugins resolve from the Gradle Plugin Portal automatically when applied in the plugins { } block by id.

plugins {
    id("org.jetbrains.kotlin.plugin.serialization") version "2.0.0"
}

Excluding Transitive Dependencies

You can exclude an unwanted transitive dependency that comes along with another library.

dependencies {
    implementation("com.example:lib:1.0") {
        exclude(group = "org.slf4j", module = "slf4j-api")
    }
}

Forcing a Version

Resolve conflicts by forcing a specific version through a resolution strategy.

configurations.all {
    resolutionStrategy {
        force("com.google.guava:guava:33.2.1-jre")
    }
}

Inspecting the Dependency Tree

Use the dependencies task to see the resolved graph and diagnose conflicts.

// ./gradlew dependencies
// ./gradlew app:dependencies --configuration runtimeClasspath

Choosing the Right Configuration

Default to implementation. Use api sparingly, testImplementation for tests, and the compileOnly/runtimeOnly pair for phase-specific needs.

Quick Check

A logging library is only used inside your module and never appears in your public types. Which configuration is best?

Recap

You configured the build:

  • Configurations: implementation, api, compileOnly, runtimeOnly, testImplementation
  • Apply plugins by id (with version) or as core plugins
  • Exclude/force versions and inspect the tree

Next: writing custom tasks.

Free to start

Learn Kotlin with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
51
Lessons
203

Frequently Asked Questions

Is the “Dependencies and Plugins” lesson free?

Yes — any 3 lessons of the Kotlin Academy learning path, including “Dependencies and Plugins”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The Kotlin Academy course includes 4 lessons in total.

What will I learn in “Dependencies and Plugins”?

Configure the build. You practise Kotlin Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Kotlin Academy?

No prior experience is required. Kotlin Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.

How long does the “Dependencies and Plugins” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Kotlin Academy lesson?

Yes. Every Kotlin Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Gradle Kotlin DSL
  2. Dependencies and Plugins
  3. Custom Tasks
  4. Version Catalogs
← Back to Kotlin Academy