Build error while upgrading to gradle 4.5

I was trying to upgrade gradle from 4.4 to 4.5 and I am getting following error:

Caused by: groovy.lang.MissingPropertyException: No such property: values for class: org.gradle.api.internal.tasks.DefaultTaskDependency
Possible solutions: values

Code that trigger this error:

build.dependsOn = build.taskDependencies.values - ‘check’

I didn’t find any solution on google. I have very limited knowledge on gradle. Build is working with v4.4 but breaks with v4.5. Any help will be much appreciated.