I use a few static code analysis plugins like checkstyle and PMD that can be configured to use a specific version of the underlying tools. I also use convention plugins, i.e. I have a checkstyle specific plugin that I can include from my generic Java convention plugin.
plugins {
checkstyle
}
checkstyle {
maxWarnings = 0
toolVersion = "10.4"
}
I’d like to move the version constraint “10.4” to some central place. For regular dependency versions I use a platform project with dependencies.constraints
. With Groovy I was able to create (and include) a simple versions convention plugin that only defines checkstyle { toolVersion = "10.4" }
. However, with Kotlin this only works if I also include the “checkstyle” plugin from said version plugin. Furthermore, I don’t think (implictly?) including “checkstyle” from the versions plugin is a good idea, especially if (in the future) I don’t want to have checkstyle at all.
I tried using PluginManager.withPlugin
. However, I don’t see how I can check the type of the returned AppliedPlugin
instance. Before I start throwing “instanceof” and type casts at the problem, I’d like to know:
What’s a better way of defining versions that are hidden in plugin properties?