Using gradle property for plugin dep and jar deps

We have this in gradle.properties

webpiecesVersion = 2.1.2

and in our global.gradle file (sucked in by all gradle files) we have a list of deps

       'web-webserver':      "org.webpieces.server:http-webserver:${webpiecesVersion}",
       'web-webserver-test': "org.webpieces.server:http-webserver-test:${webpiecesVersion}",
       'web-devrouter':      "org.webpieces.server:http-router-dev:${webpiecesVersion}",

Then, lastly, we have this plugin which SHOULD be the same version so when the user modifies gradle.properties, the version of the plugin changes too, but we can’t seem to use a property here. Is there any type of work around so that users only have the one gradle property to do an upgrade each time? Users keep getting this wrong as we generate a template and they have no idea that there is 2 locations

plugins {
    id 'org.webpieces.templatecompiler' version '2.1.2'
}

We would prefer

plugins {
id ‘org.webpieces.templatecompiler’ version ‘${webpiecesVersion}’
}

Is that not possible? Is there some sort of workaround? We prefer kludgy code with 1 property over having 2 locations to modify (since users will get that wrong 99% of time)

Have you considered/evaluated the version catalogs feature available in modern Gradle versions?
Specifically, the toml format allows you to specify a version in [versions] section and then use the same version.ref in [libraries] and [plugins]. If you need to share these versions across builds, then the version-catalog plugin may be of interest.

1 Like