-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathspotless.code-format.gradle.kts
More file actions
96 lines (85 loc) · 2.35 KB
/
spotless.code-format.gradle.kts
File metadata and controls
96 lines (85 loc) · 2.35 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
import com.diffplug.gradle.spotless.FreshMarkExtension
plugins {
id("com.diffplug.spotless")
}
val freshMarkSetup: (FreshMarkExtension) -> Unit = {
it.target("*.md")
it.propertiesFile(rootProject.file("gradle.properties"))
it.properties {
put("yes", ":+1:")
put("no", ":white_large_square:")
}
it.leadingTabsToSpaces(2)
it.endWithNewline()
}
spotless {
if (project == rootProject) {
freshmark {
freshMarkSetup(this)
ratchetFrom(null)
}
} else {
java {
ratchetFrom("origin/main")
bumpThisNumberIfACustomStepChanges(1)
licenseHeaderFile(rootProject.file("gradle/spotless.license"))
importOrderFile(rootProject.file("gradle/spotless.importorder"))
eclipse().configFile(rootProject.file("gradle/spotless.eclipseformat.xml"))
trimTrailingWhitespace()
removeUnusedImports()
formatAnnotations()
forbidWildcardImports()
forbidRegex(
"ForbidGradleInternal",
"import org\\.gradle\\.api\\.internal\\.(.*)",
"Don't use Gradle's internal API"
)
}
}
groovyGradle {
target("*.gradle", "gradle/*.gradle")
greclipse().configFile(
rootProject.files(
"gradle/spotless.eclipseformat.xml",
"gradle/spotless.groovyformat.prefs"
)
)
}
format("dotfiles") {
target(".gitignore", ".gitattributes", ".editorconfig")
leadingTabsToSpaces(2)
trimTrailingWhitespace()
endWithNewline()
}
}
// Extra freshmark logic from spotless-freshmark.gradle
if (project == rootProject) {
val versionLast = rootProject.extra["versionLast"]?.toString()
val versionNext = rootProject.extra["versionNext"]?.toString()
if (versionLast != null && versionNext != null) {
if (tasks.names.contains("changelogCheck")) {
spotless {
freshmark {
properties {
put("versionLast", versionLast)
}
}
}
// create a freshmark apply task manually
val freshMarkApply = FreshMarkExtension(spotless)
freshMarkSetup(freshMarkApply)
freshMarkApply.properties {
put("versionLast", versionNext)
}
val changelogBumpFreshMark = freshMarkApply.createIndependentApplyTask("changelogBumpFreshmark")
changelogBumpFreshMark.dependsOn(tasks.named("changelogBump"))
val changelogBumpFreshMarkGitAdd by tasks.registering(Exec::class) {
dependsOn(changelogBumpFreshMark)
commandLine("git", "add", "*.md")
}
tasks.named("changelogPush") {
dependsOn(changelogBumpFreshMarkGitAdd)
}
}
}
}