Slackbot
05/03/2022, 2:18 PMChris Lee
05/03/2022, 2:21 PMVampire
05/03/2022, 2:23 PMbuildSrc/build.gradle(.kts) by importing it in the buildSrc/settings.gradle(.kts).Thomas Broyer
05/04/2022, 7:56 AMdependencies {
implementation(plugin(id = "com.diffplug.spotless", version = "5.14.1"))
}
// <https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers>
fun plugin(id: String, version: String) = "$id:$id.gradle.plugin:$version"
and am now using version catalogs with a similar function:
dependencies {
implementation(plugin(libs.plugins.spotless))
}
// <https://github.com/gradle/gradle/issues/17963>
// <https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers>
fun plugin(plugin: Provider<PluginDependency>) = plugin.map { "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" }joschi
05/04/2022, 7:59 AMdependencies {
classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.6"
}
id "com.github.spotbugs" version "5.0.6"joschi
05/04/2022, 8:04 AMThomas Broyer
05/04/2022, 8:04 AMplugins { id("com.github.spotbugs") } (see the link in comment next to the function). The thing is, that plugin marker artifact is only a POM that depends on the actual artifact of the plugin: https://plugins.gradle.org/m2/com/github/spotbugs/com.github.spotbugs.gradle.plugin/5.0.6/com.github.spotbugs.gradle.plugin-5.0.6.pomJavi
05/04/2022, 1:44 PMThomas Broyer
05/04/2022, 1:49 PMThomas Broyer
05/04/2022, 1:50 PMSince theDSL block only allows for declaring plugins by their globally unique pluginplugins {}andidproperties, Gradle needs a way to look up the coordinates of the plugin implementation artifact. To do so, Gradle will look for a Plugin Marker Artifact with the coordinatesversion. This marker needs to have a dependency on the actual plugin implementation.plugin.id:plugin.id.gradle.plugin:plugin.version
Vampire
05/04/2022, 2:28 PM