https://gradle.com/ logo
#community-support
Title
# community-support
a

Adam

03/14/2023, 5:49 PM
one feature that I liked about buildSrc is that I could define the Maven coordinates of all the plugins I wanted to use in
buildSrc/build.gradle.kts
, and the plugin versions would be the same in both the convention plugins, and if they were applied directly in subprojects. I liked that there was one central place were the plugin versions were defined. When I change from buildSrc to an included build, I lose this feature. Even though the plugins are still defined in
build-logic/build.gradle.kts
I have to specify the plugin version again in subprojects. This means there's not a central place where plugins are defined. I know there's plugin aliases in
libs.versions.toml
, but I'm not a fan of this because the kts implementation is janky ("val Project.libs: LibrariesForLibs' can't be called in this context..."), and I have to define both the plugin ID and the Maven coordinates. I preferred the buildSrc method. Is there a nice way of having all the plugins defined in one place while using included build?
e

ephemient

03/14/2023, 5:51 PM
c

Chris Lee

03/14/2023, 5:51 PM
Doesn’t address all the challenges but this snippet for dependencies allows to use the plugin id instead of coordinates:
Copy code
public fun DependencyHandlerScope.plugin(id: String, version: String): String =
    "$id:$id.gradle.plugin:$version"

public fun DependencyHandlerScope.plugin(plugin: Provider<PluginDependency>): Provider<String> =
    plugin.map { "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" }
e

ephemient

03/14/2023, 5:52 PM
and even if it shows up as red in the IDE in earlier versions, it still works
a

Adam

03/14/2023, 5:54 PM
this project is stuck on v7 for now
e

ephemient

03/14/2023, 5:58 PM
I use version catalog plugin aliases even in v7 and ignore the IDE when it isn't being helpful
13 Views