### Install Kotlinter Plugin (Multi-module Root - Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Apply the Kotlinter plugin to the root project in a multi-module setup using Groovy DSL. This is typically done with 'apply false'. ```groovy plugins { id 'org.jmailen.kotlinter' version "" apply false } ``` -------------------------------- ### Install Git Pre-Push Hook (Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Automatically install the Kotlinter pre-push Git hook when the build runs, ensuring code is linted and formatted before pushing. This configuration should be in the root project's build.gradle. ```groovy tasks.named('check') { dependsOn 'installKotlinterPrePushHook' } ``` -------------------------------- ### Install Kotlinter Plugin (Multi-module Root - Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Apply the Kotlinter plugin to the root project in a multi-module setup using Kotlin DSL. This is typically done with 'apply false'. ```kotlin plugins { id("org.jmailen.kotlinter") version "" apply false } ``` -------------------------------- ### Install Git Pre-Push Hook (Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Automatically install the Kotlinter pre-push Git hook when the build runs, ensuring code is linted and formatted before pushing. This configuration should be in the root project's build.gradle.kts. ```kotlin tasks.check { dependsOn("installKotlinterPrePushHook") } ``` -------------------------------- ### Install Kotlinter Plugin (Single Module - Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Apply the Kotlinter plugin to a single-module project using Groovy DSL. ```groovy plugins { id "org.jmailen.kotlinter" version "" } ``` -------------------------------- ### Install Kotlinter Plugin (Single Module - Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Apply the Kotlinter plugin to a single-module project using Kotlin DSL. ```kotlin plugins { id("org.jmailen.kotlinter") version "" } ``` -------------------------------- ### Build Project Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/CLAUDE.md Use this command to build the entire project. ```bash ./gradlew build ``` -------------------------------- ### Run All Tests Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/CLAUDE.md Execute all tests in the project. ```bash ./gradlew test ``` -------------------------------- ### Run Integration Tests Projects Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/CLAUDE.md Execute linting and formatting tasks for integration test projects. ```bash ../gradlew lintKotlin formatKotlin ``` -------------------------------- ### Configure Kotlinter Plugin Options (Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Configure plugin options such as ktlint version, failure handling, and reporters using Groovy DSL. Defaults are shown and can be omitted if desired. ```groovy kotlinter { ktlintVersion = "1.5.0" ignoreFormatFailures = true ignoreLintFailures = false reporters = ['checkstyle'] } ``` -------------------------------- ### Format Specific Source Set Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/CLAUDE.md Format Kotlin code for a specific source set, e.g., 'main'. ```bash ./gradlew formatKotlinMain ``` -------------------------------- ### Configure Kotlinter Plugin Options (Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Configure plugin options such as ktlint version, failure handling, and reporters using Kotlin DSL. Defaults are shown and can be omitted if desired. ```kotlin kotlinter { ktlintVersion = "1.5.0" ignoreFormatFailures = true ignoreLintFailures = false reporters = arrayOf("checkstyle") } ``` -------------------------------- ### Create Custom Lint Task (Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Register a custom LintTask to handle additional source code or specific configurations. Allows defining source directories and multiple report outputs. ```groovy import org.jmailen.gradle.kotlinter.tasks.LintTask import org.jmailen.gradle.kotlinter.tasks.FormatTask tasks.register('ktLint', LintTask) { group 'verification' source files('src') reports = [ 'plain': file('build/lint-report.txt'), 'json' : file('build/lint-report.json') ] } ``` -------------------------------- ### Create Custom Format Task (Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Register a custom FormatTask to handle additional source code or specific configurations. Allows defining source directories and a single report output. ```kotlin import org.jmailen.gradle.kotlinter.tasks.LintTask import org.jmailen.gradle.kotlinter.tasks.FormatTask tasks.register("ktFormat") { group = "formatting" source(files("src")) report.set(file("build/format-report.txt")) } ``` -------------------------------- ### Create Custom Format Task (Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Register a custom FormatTask to handle additional source code or specific configurations. Allows defining source directories and a single report output. ```groovy import org.jmailen.gradle.kotlinter.tasks.LintTask import org.jmailen.gradle.kotlinter.tasks.FormatTask tasks.register('ktFormat', FormatTask) { group 'formatting' source files('src/test') report = file('build/format-report.txt') } ``` -------------------------------- ### Create Custom Lint Task (Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Register a custom LintTask to handle additional source code or specific configurations. Allows defining source directories and multiple report outputs. ```kotlin import org.jmailen.gradle.kotlinter.tasks.LintTask import org.jmailen.gradle.kotlinter.tasks.FormatTask tasks.register("ktLint") { group = "verification" source(files("src")) reports.set( mapOf( "plain" to file("build/lint-report.txt"), "json" to file("build/lint-report.json") ) ) } ``` -------------------------------- ### Format Kotlin Code Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/CLAUDE.md Automatically format all Kotlin code according to ktlint rules. ```bash ./gradlew formatKotlin ``` -------------------------------- ### Run Single Test Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/CLAUDE.md Run a specific test case using its fully qualified name. ```bash ./gradlew test --tests "org.jmailen.gradle.kotlinter.functional.KotlinProjectTest.testName" ``` -------------------------------- ### Lint Specific Source Set Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/CLAUDE.md Lint Kotlin code for a particular source set, e.g., 'main'. ```bash ./gradlew lintKotlinMain ``` -------------------------------- ### Apply Kotlinter Plugin (Multi-module Module - Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Apply the Kotlinter plugin to an individual module within a multi-module project using Groovy DSL. ```groovy plugins { id 'org.jmailen.kotlinter' } ``` -------------------------------- ### Lint Kotlin Code Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/CLAUDE.md Apply ktlint rules to lint all Kotlin code in the project. ```bash ./gradlew lintKotlin ``` -------------------------------- ### Add Custom Ktlint Rulesets (Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Declare custom ktlint RuleSets as dependencies using the 'ktlint' configuration in Groovy DSL. This allows integrating custom linting rules. ```groovy dependencies { ktlint project(':extra-rules') ktlint 'org.other.ktlint:custom-rules:1.0' } ``` -------------------------------- ### Apply Kotlinter Plugin (Multi-module Module - Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Apply the Kotlinter plugin to an individual module within a multi-module project using Kotlin DSL. ```kotlin plugins { id("org.jmailen.kotlinter") } ``` -------------------------------- ### Add Custom Ktlint Rulesets (Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Declare custom ktlint RuleSets as dependencies using the 'ktlint' configuration in Kotlin DSL. This allows integrating custom linting rules. ```kotlin dependencies { ktlint(project(":extra-rules")) ktlint("org.other.ktlint:custom-rules:1.0") } ``` -------------------------------- ### Exclude Generated Source Files (Groovy) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Customize a specific lint task, like 'lintKotlinMain', to exclude specific directories, such as '/src/generated', from being processed. This is useful for build-generated code. ```groovy tasks.named("lintKotlinMain") { exclude { it.file.path.contains("/src/generated") } } ``` -------------------------------- ### Exclude Generated Source Files (Kotlin) Source: https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md Customize LintTask and FormatTask to exclude specific directories, such as '/src/generated', from being processed. This is useful for build-generated code. ```kotlin tasks.withType { exclude { it.file.path.contains("/src/generated") } } tasks.withType { exclude { it.file.path.contains("/src/generated") } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.