-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspotless.gradle
More file actions
36 lines (32 loc) · 1013 Bytes
/
spotless.gradle
File metadata and controls
36 lines (32 loc) · 1013 Bytes
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
spotless {
format 'misc', {
// define the files to apply `misc` to
target '**/*.gradle', '**/*.md', '**/.gitignore'
// define the steps to apply to those files
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()
}
kotlin {
target '**/*.kt'
targetExclude '**/*Test.kt'
ktlint().userData(
// This will fucking strict you to code before this line ------------------------>
['max_line_length': '100']
)
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 spotlessApply
git add .
"""
"chmod +x .git/hooks/pre-commit".execute()
}