Calling method from rootProject in subproject fails

Gradle Version: 2.14
Operating System: Windows 7 enterprise
Is this a regression? If yes, which version of Gradle do you know it last worked for? 2.13

I divide my build login into gradle scripts and store them in my rootDir/gradle dir. In my root build.gradle I have the following method:

File script(String name) {
    project.file("gradle/${name}.gradle")
}

This way I can call a script f.i. apply from: script('database') will apply the following script: gradle/database.gradle

When upgrading to gradle2.14, My subprojects cannot call the script-method anymore. I get the following stacktrace:
´´´
> Caused by: groovy.lang.GroovyRuntimeException: Cannot read write-only property: script
> at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeOpaqueMethod(BeanDynamicObject.java:418)
> at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:397)
> at org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:169)
> at org.gradle.internal.metaobject.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:96)
> at org.gradle.internal.metaobject.MixInClosurePropertiesAsMethodsDynamicObject.invokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:30)
> at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:59)
> at shared_subprojects_5ljquxdumxtbgew79two11hks$_run_closure1.doCall(C:\dev\projects\map-repository\gradle\shared-subprojects.gradle:48)
> at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
> at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:107)
> at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:888)
> at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:893)
> at org.gradle.api.internal.project.AbstractProject.subprojects(AbstractProject.java:876)
> at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:374)
> at org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:169)
> at org.gradle.internal.metaobject.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:96)
> at org.gradle.internal.metaobject.MixInClosurePropertiesAsMethodsDynamicObject.invokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:30)
> at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)
> at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
> at shared_subprojects_5ljquxdumxtbgew79two11hks.run(C:\projects\myProject\gradle\shared-subprojects.gradle:3)
> at org.gradle.gr´´´oovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
> … 70 more

Hey Jan,

I tried to reproduce your issue and I can see the different behaviour you describe when running it with Gradle 2.14. In general Gradle does not officially support having methods in the rootproject declared and sharing it with subprojects. Instead you should use an extension for this:

ext.myScript = {name -> project.file(...)}

But this aside, I think the problem in your special case is that your script method clashes with setScript declared on ProjectInternal if you rename you script(...) to something (e.g. gradlescript or myscript) things should work again with 2.14.