Slackbot
01/22/2024, 10:25 AMVampire
01/22/2024, 10:56 AMtrimTrailingWhitespace() somewhere.
If I use what you pasted it works fine, if I double that line, I get the same error.
Besides that this is not really so much a Gradle question, but more a question to the maintainers of that plugin.Jean Tuffier
01/22/2024, 11:03 AMVampire
01/22/2024, 11:04 AMVampire
01/22/2024, 11:04 AMJean Tuffier
01/22/2024, 11:57 AMspotlessBlock lies inside allprojects , probably to configure it for every module. That’s probably why it failsJean Tuffier
01/22/2024, 11:57 AMbiold.gradle or is there a clever way of doing this?Jean Tuffier
01/22/2024, 12:03 PMsubprojects instead, I’ll try with thatVampire
01/22/2024, 12:06 PMallprojects { ... }, subprojects { ... }, project(...) { ... } or similar means of doing cross-project configuration is actually bad practice and highly discouraged, as it immediately introduces project coupling and works against more sophisticated Gradle features and optimizations, besides making builds harder to read and harder to maintain.
Instead you should consider using convention plugins, for example in buildSrc or an included build like gradle/build-logic for example implemented as precomplied script plugins.Vampire
01/22/2024, 12:06 PMJean Tuffier
01/24/2024, 8:17 AMclass SpotlessConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(libs.findPlugin("spotless").get())
configure<com.diffplug.gradle.spotless.SpotlessExtension> { <-- this type is not resolved since the plugin is applied dynamically I guess
configureSpotless(this)
}
}
}
}
How can I use the type com.diffplug.gradle.spotless.SpotlessExtension from there?Vampire
01/24/2024, 8:47 AMJean Tuffier
01/24/2024, 9:09 AM