-
Notifications
You must be signed in to change notification settings - Fork 28
/
spotless.gradle
36 lines (33 loc) · 940 Bytes
/
spotless.gradle
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
apply plugin: "com.diffplug.spotless"
spotless {
kotlin {
target 'api/*.kt'
target 'appconfig/*.kt'
target 'design/*.kt'
target 'holder/*.kt'
target 'introduction/*.kt'
target 'qrscanner/*.kt'
target 'shared/*.kt'
ktlint()
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
task createSpotlessPreCommitHook() {
def gitHooksDirectory = new File("$project.rootDir/.git/hooks/")
if (!gitHooksDirectory.exists()) gitHooksDirectory.mkdirs()
new File("$project.rootDir/.git/hooks", "pre-commit").text = """
#!/bin/bash
echo "Running spotless check"
./gradlew spotlessCheck
if [ \$? -eq 0 ]
then
echo "Spotless check succeeded"
else
echo "Spotless check failed" >&2
exit 1
fi
"""
"chmod +x .git/hooks/pre-commit".execute()
}