Gradle Kotlin DSL Converter

July 11, 2026 · View on GitHub

Image of GradleKotlinConverter

Gradle Kotlin DSL Converter

A powerful tool to simplify the migration from Gradle's Groovy DSL to Kotlin DSL for Android and other Gradle projects.

Image of website

Visit https://gradle-kotlin-converter.vercel.app/ to use the converter.

Overview

This tool helps you migrate Gradle build scripts from Groovy DSL to Kotlin DSL. It automates the repetitive mechanical changes so you can focus on the parts that actually need manual attention.

It works with Android projects as well as pure JVM, Kotlin, and other Gradle builds. Think of it like Android Studio's Java → Kotlin converter — a powerful starting point rather than a perfect one-shot solution.

Features

  • Converts Groovy Gradle scripts to Kotlin DSL
  • Handles the most common syntax and idiomatic changes
  • Supports Android, JVM, Kotlin, and general Gradle projects
  • Adds helpful migration warnings for deprecated AGP APIs
  • Works great as a first step (like the Java → Kotlin converter)

Getting Started

Web Interface

Visit the online converter — no setup required.

Local CLI

cd web
pnpm install

pnpm cli build.gradle
pnpm cli build.gradle > build.gradle.kts

Kotlin Script

kotlinc -script kotlin/gradlekotlinconverter.kts build.gradle
# or
./kotlin/gradlekotlinconverter.kts build.gradle

The Kotlin script covers the core conversions; web/ is the complete implementation with the full test suite and additional features.

Developing the project

cd web
pnpm install
pnpm test

Tests are a mix of focused unit tests and full-file golden fixtures in web/app/fixtures/golden/. The web/ implementation is the primary one and includes extra features like AGP migration warnings.

Supported Transformations

The converter handles the most common Groovy-to-Kotlin DSL changes. Here are some of the most frequently used transformations:

DescriptionBeforeAfter
Strings'kotlin-android'"kotlin-android"
Variablesdef appcompat = "1.0.0"val appcompat = "1.0.0"
Apply pluginsapply plugin: "kotlin-kapt"apply(plugin = "kotlin-kapt")
Dependenciesimplementation ":epoxy"implementation(":epoxy")
Maven repositoriesmaven { url "https://jitpack.io" }maven("https://jitpack.io")
SDK versions (legacy)compileSdkVersion 28compileSdk = 28
SDK versions (modern)compileSdk 36compileSdk = 36
Version code / nameversionCode 4versionCode = 4
Build typesdebuggable trueisDebuggable = true
ProGuardproguardFiles getDefault...setProguardFiles(listOf(getDefault...))
Source compatibilitysourceCompatibility = "1.8"sourceCompatibility = JavaVersion.VERSION_1_8
Includesinclude ":app", ":diffutils"include(":app", ":diffutils")
Signing configssigningConfigs { debug { ... } }signingConfigs { register("debug") { ... } }
Build typesbuildTypes { debug { ... } }buildTypes { named("debug") { ... } }
Kotlin dependencies"org.jetbrains.kotlin:kotlin-stdlib:$v"kotlin("stdlib")
Plugin blocksMultiple apply(plugin = ...)plugins { id(...) ... }
Extrasext.kotlin_version = '2.1.20'extra["kotlin_version"] = "2.1.20"

The converter also supports many modern Gradle patterns, including:

  • Version catalogs, platform() dependencies, and includeBuild
  • fileTree(mapOf(...)) and artifacts { add(...) }
  • buildFeatures, testOptions, and Kotlin compiler options
  • Modernization of legacy *SdkVersion declarations
  • Helpful AGP migration warnings (variantFilter, RenderScript, density splits, etc.)

See the golden fixtures and web/app/logic.ts for the complete set of rules and realistic before/after examples.

The tool works on both .gradle and .kts files. Even if you paste just a dependency line like implementation '...', it will correctly add parentheses and quotes.

Limitations

The converter is a best-effort tool (similar to Android Studio's Java → Kotlin converter). It will not perfectly handle every case:

  • Complex custom Groovy logic, helper methods in buildSrc, or heavy metaprogramming
  • Some ext { } blocks containing closures (the tool inserts // TODO comments for manual review)
  • Certain legacy or removed AGP/Gradle features that require larger architectural changes (the tool adds // TODO(AGP) notes where relevant)
  • Every third-party plugin's custom DSL extensions

Always review the output, run a Gradle sync, and test your build. For tricky cases, the golden fixtures and focused regression tests document current behavior.

Issue Tracking

Found a bug? Have an idea for an improvement? Feel free to add an issue.