How to build gradle source code specifying a custom version name?

I’ve modified some code of gradle to fit my team’s need, I wonder where can I set the version name and build a custom gradle.

I’ve tried modifying version.txt and set version name as “4.5-uc”, the build was successful, but when i run the custom gradle , an exception pops up as below:

Also, I’ve tried to add build property finalRelease, and modify gradle/versioning.gradle’s if finalRelease condition is true and set the custom version. Yet it didn’t work.

So the question is, how can I build a custom gradle with specific version name?

I give up, just build the gradle source code with default params to produce a snapshot version, which does no harm so far.