Skip to content

Commit 3a87c25

Browse files
authored
Change the way how additional spotless configuration is applied (#9)
1 parent f06117a commit 3a87c25

2 files changed

Lines changed: 3 additions & 16 deletions

File tree

gradle-modules/src/main/kotlin/org.sonarsource.cloud-native.code-style-conventions.gradle.kts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,13 @@ spotless {
5555
toggleOffOn()
5656
}
5757
kotlinGradle {
58+
ktlint().setEditorConfigPath(codeStyleConvention.editorConfigPath)
5859
licenseHeaderFile(licenseHeaderFile, kotlinGradleDelimiter).updateYearWithLatest(true)
5960
}
6061
format("javaMisc") {
6162
target("src/**/package-info.java")
6263
licenseHeaderFile(licenseHeaderFile, "@javax.annotation").updateYearWithLatest(true)
6364
}
64-
65-
// Apply additional project-specific configuration after the project has been evaluated and the `codeStyleConvention` extension has been initialized
66-
project.afterEvaluate {
67-
spotless {
68-
kotlinGradle {
69-
ktlint().setEditorConfigPath(codeStyleConvention.editorConfigPath)
70-
}
71-
}
72-
codeStyleConvention.spotless?.invoke(this@spotless)
73-
}
7465
}
7566

7667
tasks.check { dependsOn("spotlessCheck") }

gradle-modules/src/main/kotlin/org/sonarsource/cloudnative/gradle/CodeStyleConvention.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@
1717
package org.sonarsource.cloudnative.gradle
1818

1919
import com.diffplug.gradle.spotless.SpotlessExtension
20+
import org.gradle.api.Project
2021
import org.gradle.api.provider.Property
22+
import org.gradle.kotlin.dsl.getByType
2123

2224
interface CodeStyleConvention {
2325
val editorConfigPath: Property<String>
24-
25-
var spotless: (SpotlessExtension.() -> Unit)?
26-
27-
fun spotless(action: SpotlessExtension.() -> Unit) {
28-
spotless = action
29-
}
3026
}

0 commit comments

Comments
 (0)