Gradle bugchecks when encountering "new project.file('filename.ext')

The following build.gradle script results in an unexpected error:

def variable = new project.file('filename.ext')

The result:


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project '20160112'.
> Could not open proj class cache for build file 'C:\jdev\gradlebugs\20160112\build.gradle' (C:\Users\P58042\.gradle\caches\2.8\scripts\build_2vmut27fo9ugoxioy9ue3soz8\proj).
   > BUG! exception in phase 'semantic analysis' in source unit 'build_2vmut27fo9ugoxioy9ue3soz8' String index out of range: 23

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


Total time: 1.545 secs

I figured out that my usage was incorrect - that I needed either ‘new File(…)’ or to simply drop the ‘new’. However, given that usage, I still think this is a Gradle bug - I had expected some kind of error that referenced the offending line number in the build script. (This is not the script I was working with when I encountered the error; it took quite a while to figure out what change triggered the bugcheck.)

Thanks for the report. I’ve raised this as GRADLE-3382. I have a fix ready for this.

Wow - thanks very much!