forked from BVantur/inspektify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
83 lines (72 loc) · 2.46 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
74
75
76
77
78
79
80
81
82
83
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.ktlint) apply false
alias(libs.plugins.detekt) apply true
alias(libs.plugins.kotlin.serialization) apply true
alias(libs.plugins.swiftklib) apply false
alias(libs.plugins.mavenPublish) apply false
}
subprojects {
ktlintSetup()
detektSetup()
}
fun Project.ktlintSetup() {
apply(plugin = rootProject.libs.plugins.ktlint.get().pluginId)
configure<KtlintExtension> {
version.set("1.3.0")
enableExperimentalRules.set(true)
verbose.set(true)
filter {
exclude { it.file.path.contains("build/") }
}
}
}
fun Project.detektSetup() {
apply(plugin = rootProject.libs.plugins.detekt.get().pluginId)
dependencies {
detektPlugins(rootProject.libs.detekt.formatting)
}
detekt {
buildUponDefaultConfig = true
allRules = false
source.from(
"src/androidMain/kotlin",
"src/commonMain/kotlin",
"src/iosMain/kotlin"
)
config.setFrom("${rootProject.projectDir}/code-analysis-config/detekt/detekt.yml")
baseline = file("${rootProject.projectDir}/code-analysis-config/detekt/baseline.xml")
}
tasks.withType<Detekt>().configureEach {
exclude("**/build/**", "**/generated/**", "**/resources/**")
autoCorrect = true
reports {
xml.required.set(false)
txt.required.set(false)
md.required.set(false)
html {
required.set(true)
outputLocation.set(
layout.buildDirectory.file("reports/detekt.html")
)
}
sarif.required.set(true)
}
}
tasks.withType<Detekt>().configureEach {
jvmTarget = JvmTarget.JVM_17.target
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
jvmTarget = JvmTarget.JVM_17.target
}
}