-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathSpotlessConventionPlugin.kt
More file actions
55 lines (53 loc) 路 2.43 KB
/
Copy pathSpotlessConventionPlugin.kt
File metadata and controls
55 lines (53 loc) 路 2.43 KB
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
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.spotless.kotlin.KotlinConstants
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
class SpotlessConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.diffplug.spotless")
extensions.configure<SpotlessExtension> {
kotlin {
target("**/*.kt")
targetExclude(
"**/build/**/*.kt", // Build directory
"**/io/getstream/android/video/generated/**/*.kt" // Open Api generated code
)
ktlint()
.editorConfigOverride(
mapOf(
"ktlint_standard_max-line-length" to "disabled"
)
)
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(rootProject.file("$rootDir/spotless/copyright.kt"))
}
format("openapiGenerated") {
target("**/*.kt")
targetExclude("**/build/**/*.kt", "**/io/getstream/android/video/generated/**/*.kt")
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(rootProject.file("$rootDir/spotless/copyright.kt"),
KotlinConstants.LICENSE_HEADER_DELIMITER)
}
format("kts") {
target("**/*.kts")
targetExclude("**/build/**/*.kts", "**/io/getstream/android/video/generated/**/*.kt")
// Look for the first line that doesn't have a block comment (assumed to be the license)
licenseHeaderFile(
rootProject.file("spotless/copyright.kts"),
"(^(?![\\/ ]\\*).*$)"
)
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/**/*.xml")
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
}
}
}
}
}