{"id":21519619,"url":"https://github.com/usefulness/ktlint-gradle-plugin","last_synced_at":"2025-04-09T22:09:49.879Z","repository":{"id":40779128,"uuid":"362716386","full_name":"usefulness/ktlint-gradle-plugin","owner":"usefulness","description":"Painless, fast ktlint plugin for Gradle","archived":false,"fork":false,"pushed_at":"2025-04-09T06:39:11.000Z","size":1572,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T22:09:36.711Z","etag":null,"topics":["codestyle","gradle","gradle-plugin","jvm","kotlin","ktlint","ktlint-gradle"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jeremymailen/kotlinter-gradle","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/usefulness.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-29T06:42:33.000Z","updated_at":"2025-04-09T06:39:13.000Z","dependencies_parsed_at":"2023-10-14T17:20:21.044Z","dependency_job_id":"a5ec5500-7df0-46ff-b467-0f40a419e80e","html_url":"https://github.com/usefulness/ktlint-gradle-plugin","commit_stats":null,"previous_names":[],"tags_count":92,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usefulness%2Fktlint-gradle-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usefulness%2Fktlint-gradle-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usefulness%2Fktlint-gradle-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usefulness%2Fktlint-gradle-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/usefulness","download_url":"https://codeload.github.com/usefulness/ktlint-gradle-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119294,"owners_count":21050755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codestyle","gradle","gradle-plugin","jvm","kotlin","ktlint","ktlint-gradle"],"created_at":"2024-11-24T00:59:40.683Z","updated_at":"2025-04-09T22:09:49.852Z","avatar_url":"https://github.com/usefulness.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ktlint-gradle-plugin\n\n[![Build Status](https://github.com/usefulness/ktlint-gradle-plugin/workflows/Build%20Project/badge.svg)](https://github.com/usefulness/ktlint-gradle-plugin/actions)\n[![Latest Version](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/io/github/usefulness/ktlint-gradle-plugin/maven-metadata.xml?label=gradle)](https://plugins.gradle.org/plugin/io.github.usefulness.ktlint-gradle-plugin)\n![Maven Central](https://img.shields.io/maven-central/v/io.github.usefulness/ktlint-gradle-plugin)\n\nGradle wrapper for [pinterest/ktlint](https://github.com/pinterest/ktlint)\n\n### Installation\n\nAvailable on:\n\n- [Gradle Plugin Portal](https://plugins.gradle.org/plugin/io.github.usefulness.ktlint-gradle-plugin)\n- [Maven Central](https://mvnrepository.com/artifact/io.github.usefulness/ktlint-gradle-plugin)\n\n#### Apply the plugin\n\n```groovy\nplugins {\n    id(\"io.github.usefulness.ktlint-gradle-plugin\") version \"{{version}}\"\n}\n```\n\n##### (Optional) Managing `ktlint` version with Renovate/Dependaot\nGiven the plugin is just a wrapper and follows its own release cycle, it may a good practice to manually control `ktlint` tool version. One can achieve it by defining full ktlint version dependency and passing resolved ktlint version to the `ktlint` extension. Version Catalog example:\n```toml\n[versions]\nktlint = \"x.y.z\"\n\n[libraries]\nktlint-cli = { module = \"com.pinterest.ktlint:ktlint-cli\", version.ref = \"ktlint\" } \n```\n\\+ then \n```groovy\nktlint {\n    ktlintVersion = libs.versions.ktlint.get()\n}\n```\n\n\n### Compatibility\n\n| plugin version | min gradle version | min ktlint version |\n|----------------|--------------------|--------------------|\n| 0.7.0+         | 8.0                | 1.0.0              |\n| 0.5.0+         | 7.6                | 1.0.0              |\n| 0.4.0+         | 7.6                | 0.50.0             |\n| 0.3.0+         | 7.6                | 0.49.0             |\n| 0.1.0+         | 7.6                | 0.48.0             |\n\n### Features\n\n- Supports Kotlin Gradle plugins:\n    - [JVM](https://plugins.gradle.org/plugin/org.jetbrains.kotlin.jvm)\n    - [Multiplatform](https://plugins.gradle.org/plugin/org.jetbrains.kotlin.multiplatform)\n    - [Android](https://plugins.gradle.org/plugin/org.jetbrains.kotlin.android)\n    - [JS](https://plugins.gradle.org/plugin/org.jetbrains.kotlin.js)\n- Supports `.kt` and `.kts` files\n- Leverages latest Gradle APIs (cacheable, incremental tasks using Gradle Worker API)   \n- Configurable reporters\n\n### Tasks\n\nWhen your project uses one of the supported Kotlin Gradle plugins, the plugin adds these tasks:\n\n- `./gradlew formatKotlin`: format Kotlin source code according to `ktlint` rules or warn when auto-format not possible.\n\n- `./gradlew lintKotlin`: report Kotlin lint errors and by default fail the build.\n\nAlso `check` becomes dependent on `lintKotlin`.\n\nGranular tasks are added for each source set in the project: `formatKotlin`*`SourceSet`* and `lintKotlin`*`SourceSet`*.\n\n### Configuration\n\nOptions can be configured in the `ktlint` extension:\n\n```groovy\nktlint {\n    ignoreFailures = false\n    reporters = [\"checkstyle\", \"html\", \"json\", \"plain\", \"sarif\"]\n    experimentalRules = true\n    disabledRules = [\"no-wildcard-imports\", \"experimental:annotation\", \"your-custom-rule:no-bugs\"]\n    ktlintVersion = \"2.0.0-SNAPSHOT\"\n    chunkSize = 50\n    baselineFile.set(file(\"config/ktlint_baseline.xml\"))\n    ignoreFilesUnderBuildDir = true\n}\n```\n\n- `ignoreFailures` - makes the `LintTask` tasks always pass\n- `reporters` - defines enable [reporters](https://pinterest.github.io/ktlint/install/cli/#violation-reporting) for all\n  tasks.\n- `experimentalRules` - enables rules from ktlint [Experimental](https://pinterest.github.io/ktlint/rules/experimental/)\n  ruleset.\n- `disabledRules` - can include an array of rule ids you wish to disable\n- `ktlintVersion` There is a basic support for overriding ktlint version, but the plugin doesn't guarantee backwards\n  compatibility with all `ktlint` versions.\n  Errors like `java.lang.NoSuchMethodError:` or `com/pinterest/ktlint/core/KtLint$Params` can be thrown if\n  provided `ktlint` version isn't compatible with the latest ktlint apis.\n\n- `chunkSize` - defines how many files will be processed by a single gradle worker in parallel\n- `baselineFile` - points at location of baseline file containing _known_ offenses that will be ignored during `lintKotlin` task execution\n- `ignoreFilesUnderBuildDir` - This allows to ignore generated sources. This is a workaround for https://youtrack.jetbrains.com/issue/KT-45161. Setting the value to `false` restores default behavior and will run ktlint against all sources returned by KGP  \n- `editorConfigValidation` - One of `None`, `PrintWarningLogs`, `BuildFailure`.\n  - Currently, this only validates if any of the _typical_ editorconfig location contain `root=true` entry. This is highly recommended to ensure the builds are deterministic across machines  \n\n### Customizing Tasks\n\nThe `formatKotlin`*`SourceSet`* and `lintKotlin`*`SourceSet`* tasks inherit\nfrom [SourceTask](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceTask.html)\nso you can customize includes, excludes, and source.\n\n```groovy\ntasks.named(\"lintKotlinMain\") {\n    exclude(\"com/example/**/generated/*.kt\")\n}\n```\n\nNote that exclude paths are relative to the package root.\n\n#### Advanced\n\nBy default, Gradle workers will use 256MB of heap size. To adjust this setting use:\n\n```groovy\nimport io.github.usefulness.tasks.KtlintWorkTask\n\ntasks.withType(KtlintWorkTask).configureEach {\n    workerMaxHeapSize.set(\"512m\")\n}\n```\n\n### Custom Rules\n\nYou can add custom `ktlint` RuleSets using the `ktlintRuleSet` configuration dependency:\n\n```groovy\ndependencies {\n    ktlintRuleSet(files(\"libs/my-custom-ktlint-rules.jar\"))\n    ktlintRuleSet(project(\":ktlint-custom-rules\"))\n    ktlintRuleSet(\"org.other.ktlint:custom-rules:1.0\")\n    ktlintRuleSet(\"io.nlopez.compose.rules:ktlint:0.3.3\")\n}\n```\n\nCredits\n---\n\n\u003cimg src=\"https://www.yourkit.com/images/yklogo.png\" alt=\"YourKit logo\" /\u003e\n\nYourKit supports open source projects with innovative and intelligent tools\nfor monitoring and profiling Java and .NET applications.\nYourKit is the creator of \u003ca href=\"https://www.yourkit.com/java/profiler/\"\u003eYourKit Java Profiler\u003c/a\u003e,\n\u003ca href=\"https://www.yourkit.com/.net/profiler/\"\u003eYourKit .NET Profiler\u003c/a\u003e,\nand \u003ca href=\"https://www.yourkit.com/youmonitor/\"\u003eYourKit YouMonitor\u003c/a\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusefulness%2Fktlint-gradle-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusefulness%2Fktlint-gradle-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusefulness%2Fktlint-gradle-plugin/lists"}