-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
73 lines (62 loc) · 2.34 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.report.ReportMergeTask
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
// https://github.com/detekt/detekt
alias(libs.plugins.detekt)
}
apply(plugin = "android-reporting")
val detektReportMerge by tasks.registering(ReportMergeTask::class) {
output.set(rootProject.layout.buildDirectory.file("reports/detekt.sarif"))
}
allprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")
detekt {
buildUponDefaultConfig = false // preconfigure defaults
allRules = false // activate all available (even unstable) rules.
source.setFrom("src/main/java", "src/main/kotlin")
config.setFrom("../config/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior
baseline = file("$projectDir/detekt-baseline.xml") // a way of suppressing issues before introducing detekt
ignoredBuildTypes = listOf("release")
autoCorrect = true
}
tasks.withType<Detekt>().configureEach {
jvmTarget = "11"
reports {
xml.required.set(false)
html.required.set(true)
txt.required.set(false)
sarif.required.set(true)
md.required.set(false)
}
finalizedBy(detektReportMerge)
}
dependencies {
detektPlugins(libs.detekt.formatting)
}
detektReportMerge {
input.from(tasks.withType<Detekt>().map { it.sarifReportFile })
}
}
val clean by tasks.registering(Delete::class) {
delete(rootProject.layout.buildDirectory)
}
/*
* https://detekt.dev/docs/gettingstarted/git-pre-commit-hook
* https://medium.com/@alistair.cerio/android-ktlint-and-pre-commit-git-hook-5dd606e230a9
*/
val installGitHook by tasks.registering(Copy::class) {
description = "Adding Git hook script to local working copy"
from(rootProject.file("git_hooks/pre-commit"))
into(rootProject.file(".git/hooks"))
filePermissions {
unix("rwxr-xr-x")
}
doFirst {
delete(rootProject.file(".git/hooks/pre-commit"))
}
}
tasks.getByPath(":data:preBuild").dependsOn(":installGitHook")