|
| 1 | +import com.diffplug.gradle.spotless.SpotlessExtension |
| 2 | + |
1 | 3 | plugins {
|
2 | 4 | id("com.diffplug.spotless")
|
3 | 5 | }
|
4 | 6 |
|
5 | 7 | spotless {
|
6 | 8 | java {
|
7 | 9 | googleJavaFormat()
|
8 |
| - licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|public|// Includes work from:)") |
| 10 | + licenseHeaderFile( |
| 11 | + rootProject.file("buildscripts/spotless.license.java"), |
| 12 | + "(package|import|public|// Includes work from:)" |
| 13 | + ) |
| 14 | + toggleOffOn() |
9 | 15 | target("src/**/*.java")
|
10 | 16 | }
|
11 | 17 | kotlinGradle {
|
12 |
| - ktlint().editorConfigOverride(mapOf( |
13 |
| - "indent_size" to "2", |
14 |
| - "continuation_indent_size" to "2", |
15 |
| - "max_line_length" to "160", |
16 |
| - "ktlint_standard_no-wildcard-imports" to "disabled", |
17 |
| - // ktlint does not break up long lines, it just fails on them |
18 |
| - "ktlint_standard_max-line-length" to "disabled", |
19 |
| - // ktlint makes it *very* hard to locate where this actually happened |
20 |
| - "ktlint_standard_trailing-comma-on-call-site" to "disabled", |
21 |
| - // depends on ktlint_standard_wrapping |
22 |
| - "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", |
23 |
| - // also very hard to find out where this happens |
24 |
| - "ktlint_standard_wrapping" to "disabled" |
25 |
| - )) |
| 18 | + // not sure why it's not using the indent settings from .editorconfig |
| 19 | + ktlint().editorConfigOverride( |
| 20 | + mapOf( |
| 21 | + "indent_size" to "2", |
| 22 | + "continuation_indent_size" to "2", |
| 23 | + "max_line_length" to "160", |
| 24 | + "ktlint_standard_no-wildcard-imports" to "disabled", |
| 25 | + // ktlint does not break up long lines, it just fails on them |
| 26 | + "ktlint_standard_max-line-length" to "disabled", |
| 27 | + // ktlint makes it *very* hard to locate where this actually happened |
| 28 | + "ktlint_standard_trailing-comma-on-call-site" to "disabled", |
| 29 | + // depends on ktlint_standard_wrapping |
| 30 | + "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", |
| 31 | + // also very hard to find out where this happens |
| 32 | + "ktlint_standard_wrapping" to "disabled", |
| 33 | + // we use variable names like v1_10Deps |
| 34 | + "ktlint_standard_property-naming" to "disabled", |
| 35 | + // prevent moving comment to next line in latestDepTestLibrary("xxx") { // see xxx module |
| 36 | + "ktlint_standard_function-literal" to "disabled" |
| 37 | + ) |
| 38 | + ) |
26 | 39 | }
|
27 |
| - format("misc") { |
28 |
| - // not using "**/..." to help keep spotless fast |
29 |
| - target( |
30 |
| - ".gitattributes", |
31 |
| - ".gitconfig", |
32 |
| - ".editorconfig", |
33 |
| - "*.md", |
34 |
| - "src/**/*.md", |
35 |
| - "docs/**/*.md", |
36 |
| - "*.sh", |
37 |
| - "src/**/*.properties") |
38 |
| - indentWithSpaces() |
39 |
| - trimTrailingWhitespace() |
40 |
| - endWithNewline() |
| 40 | +} |
| 41 | + |
| 42 | +// Use root declared tool deps to avoid issues with high concurrency. |
| 43 | +// see https://github.com/diffplug/spotless/tree/main/plugin-gradle#dependency-resolution-modes |
| 44 | +if (project == rootProject) { |
| 45 | + spotless { |
| 46 | + format("misc") { |
| 47 | + target( |
| 48 | + ".gitignore", |
| 49 | + ".gitattributes", |
| 50 | + ".gitconfig", |
| 51 | + ".editorconfig", |
| 52 | + "**/*.md", |
| 53 | + "**/*.sh", |
| 54 | + "**/*.dockerfile", |
| 55 | + "**/gradle.properties" |
| 56 | + ) |
| 57 | + leadingTabsToSpaces() |
| 58 | + trimTrailingWhitespace() |
| 59 | + endWithNewline() |
| 60 | + } |
| 61 | + predeclareDeps() |
| 62 | + } |
| 63 | + |
| 64 | + with(extensions["spotlessPredeclare"] as SpotlessExtension) { |
| 65 | + java { |
| 66 | + googleJavaFormat() |
| 67 | + } |
| 68 | + kotlinGradle { |
| 69 | + ktlint() |
| 70 | + } |
41 | 71 | }
|
42 | 72 | }
|
0 commit comments