A GitHub template for starting Android/Kotlin projects with static analysis, CI via GitHub Actions, and Maven Central publishing already configured.
JLLeitschuh/ktlint-gradle
A Gradle plugin that wraps ktlint to add check and auto-format tasks for Kotlin projects.
- Stars
- 1,723
- Forks
- 185
- Open issues
- 126
- Last commit
- 12 hours ago
What is it?
ktlint-gradle is a Gradle plugin that wraps the ktlint Kotlin linter and formatter, adding ready-made tasks to a Gradle build so code style can be checked and fixed without manual setup. It activates only on projects that apply a Kotlin plugin, so it targets Kotlin code rather than arbitrary files.
The plugin creates check and format tasks for every source set, plus project-wide ktlintCheck and ktlintFormat tasks, and also covers Kotlin script files. It supports the kotlin, kotlin-android, kotlin-multiplatform and Kotlin JS plugins, and can be applied through the plugins block, a version catalog, or the legacy apply method.
Configuration covers the ktlint version, baseline files, custom reporters and rulesets, file filters, and worker heap size. The plugin can also install git pre-commit hooks that run ktlint check or format on staged files.
Key features
- 01Adds ktlintCheck and ktlintFormat tasks for all source sets and Kotlin scripts.
- 02Supports kotlin, kotlin-android, kotlin-multiplatform and Kotlin JS projects.
- 03Allows a baseline file to suppress existing lint violations.
- 04Supports custom reporters and custom ktlint rulesets.
- 05Can install Git pre-commit hooks for check or format on staged files.
Use cases
- Enforcing a consistent Kotlin code style in Android or JVM Gradle builds.
- Adding lint checks to a multiplatform Kotlin project without changing build logic by hand.
- Introducing linting into a legacy codebase gradually using a baseline.
- Running style checks in CI through the ktlintCheck task.
Quick start
- 1
Add the plugin to your build script (plugins block, version set to the current release)
- 2
Add mavenCentral() to repositories so KtLint can be downloaded
- 3
Run the Gradle ktlint tasks in your project
Things to know
- The plugin only activates in projects that apply a supported Kotlin plugin.
- It requires Gradle 7.4 or newer and Kotlin 1.4 or newer.
Topics
FAQ
- What is ktlint-gradle?
- A Gradle plugin that wraps ktlint to add check and auto-format tasks for Kotlin projects. ktlint-gradle is a Gradle plugin that wraps the ktlint Kotlin linter and formatter, adding ready-made tasks to a Gradle build so code style can be checked and fixed without manual setup. It activates only on projects that apply a Kotlin plugin, so it targets Kotlin code rather than arbitrary files.
- Is ktlint-gradle free to use? What license does it have?
- ktlint-gradle is open source under the MIT license. Check the license terms before using it in commercial products.
- Is ktlint-gradle still maintained?
- Actively maintained. The last commit to ktlint-gradle was on Nov 6, 2026.
- What can I use ktlint-gradle for?
- Enforcing a consistent Kotlin code style in Android or JVM Gradle builds. Adding lint checks to a multiplatform Kotlin project without changing build logic by hand. Introducing linting into a legacy codebase gradually using a baseline. Running style checks in CI through the ktlintCheck task.
- How do I install ktlint-gradle?
- Add the plugin to your build script (plugins block, version set to the current release) Add mavenCentral() to repositories so KtLint can be downloaded Run the Gradle ktlint tasks in your project
- Where can I get ktlint-gradle?
- The source code and installation instructions are on GitHub: https://github.com/JLLeitschuh/ktlint-gradle
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
The Kotlin programming language and its compiler, standard library, and build tooling, developed by JetBrains for multiplatform development.
A Gradle plugin that builds fat/uber JARs, relocates packages, transforms files, and can shrink output with R8/ProGuard.
A Gradle plugin that publishes Java, Kotlin and Android libraries, with sources and javadoc, to Maven Central or other Nexus repositories.
A CLI tool that runs Python linters and formatters such as ruff, isort, black, mypy and flake8 directly on Jupyter Notebooks.
Build optimized Docker and OCI container images for Java applications with Maven or Gradle, without a Docker daemon.