With any new projects using gradle, this is a key point to start. Try using the 'com.palantir.consistent-versions' plugin.
I ran into an issue where a gradle plugin had stated they had a method called 'getVersion' but I couldn't use it. This was the solution to retrieve that method that the plugin had supported:
val packageGetVersion : groovy.lang.Closure<String> = project.ext["getVersion"] as groovy.lang.Closure<String>
doLast {