Dependencies and Plugins
Configure the build.
Dependencies and Plugins is a free Kotlin Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Dependency Configurations
Gradle groups dependencies by configuration, which controls when and where they are available:
implementation— compile and runtime, not exposed to consumersapi— also exposed to consumerstestImplementation— 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 runtimeClasspathChoosing 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.
Frequently asked questions
Is the “Dependencies and Plugins” lesson free?
Yes — the full text of “Dependencies and Plugins” is free to read here on the web, and the Kotlin Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Academy course, upgrade to CoddyKit PRO.
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; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
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
- Gradle Kotlin DSL
- Dependencies and Plugins
- Custom Tasks
- Version Catalogs