Created
February 25, 2021 15:09
-
-
Save tatocaster/179b18ccb3da76812c68934fc13a55e4 to your computer and use it in GitHub Desktop.
Detekt gradle tasks for multi-module project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add classpath dependency before | |
// classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion" | |
def configFile = files("$rootDir/config/detekt/detekt.yml") | |
def baselineFile = file("$rootDir/config/detekt/baseline.xml") | |
def analysisDir = file(projectDir) | |
def kotlinFiles = "**/*.kt" | |
def javaFiles = "**/*.java" | |
def resourceFiles = "**/resources/**" | |
def buildFiles = "**/build/**" | |
apply plugin: 'io.gitlab.arturbosch.detekt' | |
dependencies { | |
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion" | |
} | |
tasks { | |
task detektGenerateProjectBaseline(type: io.gitlab.arturbosch.detekt.DetektCreateBaselineTask) { | |
description = "Overrides current baseline." | |
parallel = true | |
ignoreFailures = false | |
buildUponDefaultConfig = true | |
autoCorrect = false | |
setSource(analysisDir) | |
config.setFrom(configFile) | |
baseline.set(baselineFile) | |
include(kotlinFiles) | |
include(javaFiles) | |
exclude(resourceFiles) | |
exclude(buildFiles) | |
} | |
task detektAll(type: io.gitlab.arturbosch.detekt.Detekt) { | |
description = "Runs the whole project at once." | |
parallel = true | |
ignoreFailures = false | |
buildUponDefaultConfig = true | |
autoCorrect = false | |
setSource(analysisDir) | |
config.setFrom(configFile) | |
baseline.set(baselineFile) | |
include(kotlinFiles) | |
include(javaFiles) | |
exclude(resourceFiles) | |
exclude(buildFiles) | |
reports { | |
html.enabled = true | |
xml.enabled = false | |
txt.enabled = false | |
sarif.enabled = false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment