Dependencies modification in gradle.init script

Hello,

Is there a possibility to modify gradle.build script dependencies during the execution of gradle.init script. I have been able to get build script dependencies as a DefaultDependencyHandler object but when I try to get a particular dependency name or version I receive null or unspecified.

allprojects {

    afterEvaluate {

        def dependencyHandler = getDependencies()
        println "Dependency handler " + dependencyHandler

        def dependencies = dependencyHandler.gradleApi()
        println "Dependency name: " + dependencies.name
        println "Dependency version: " + dependencies.version
        println "Dependency group: " + dependencies.group

        def buildScript = project.getBuildscript()
        def deps = buildscript.getDependencies()
        println deps.gradleApi().getName()

    }
}```