1
- import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
2
-
3
1
// Top-level build file where you can add configuration options common to all sub-projects/modules.
4
2
buildscript {
5
3
dependencies {
6
4
classpath(libs.google.oss.licenses.plugin) {
7
5
exclude(group = " com.google.protobuf" )
8
6
}
7
+ classpath(libs.spotless.gradle)
9
8
}
10
9
}
11
10
@@ -28,11 +27,14 @@ plugins {
28
27
alias(libs.plugins.kotlin.android) apply false
29
28
alias(libs.plugins.detekt)
30
29
alias(libs.plugins.detekt.compiler)
31
- alias(libs.plugins.module.graph) apply true // Plugin applied to allow module graph generation
30
+ // Plugin applied to allow module graph generation
31
+ alias(libs.plugins.module.graph) apply true
32
+ alias(libs.plugins.spotless)
32
33
}
33
34
34
35
val detektFormatting = libs.detekt.formatting
35
36
val twitterComposeRules = libs.twitter.detekt.compose
37
+ val ktlintVersion = " 1.0.1"
36
38
37
39
val reportMerge by tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMergeTask ::class ) {
38
40
output.set(rootProject.layout.buildDirectory.file(" reports/detekt/merge.html" )) // or "reports/detekt/merge.sarif"
@@ -41,15 +43,38 @@ val reportMerge by tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMe
41
43
subprojects {
42
44
apply {
43
45
plugin(" io.gitlab.arturbosch.detekt" )
46
+ plugin(" com.diffplug.spotless" )
44
47
}
45
48
46
- detekt {
49
+ tasks.withType < io.gitlab.arturbosch. detekt. Detekt > ().configureEach {
47
50
config.from(rootProject.files(" config/detekt/detekt.yml" ))
48
51
reports.xml.required.set(true )
52
+ finalizedBy(reportMerge)
49
53
}
50
54
51
- tasks.withType< io.gitlab.arturbosch.detekt.Detekt > ().configureEach {
52
- finalizedBy(reportMerge)
55
+ extensions.configure< com.diffplug.gradle.spotless.SpotlessExtension > {
56
+ kotlin {
57
+ target(" **/*.kt" )
58
+ targetExclude(" **/build/**/*.kt" )
59
+ ktlint(ktlintVersion).editorConfigOverride(
60
+ mapOf (
61
+ " android" to " true" ,
62
+ ),
63
+ )
64
+ licenseHeaderFile(rootProject.file(" spotless/copyright.kt" ))
65
+ }
66
+ format(" kts" ) {
67
+ target(" **/*.kts" )
68
+ targetExclude(" **/build/**/*.kts" )
69
+ // Look for the first line that doesn't have a block comment (assumed to be the license)
70
+ licenseHeaderFile(rootProject.file(" spotless/copyright.kts" ), " (^(?![\\ / ]\\ *).*$)" )
71
+ }
72
+ format(" xml" ) {
73
+ target(" **/*.xml" )
74
+ targetExclude(" **/build/**/*.xml" )
75
+ // Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
76
+ licenseHeaderFile(rootProject.file(" spotless/copyright.xml" ), " (<[^!?])" )
77
+ }
53
78
}
54
79
55
80
reportMerge {
0 commit comments