The following build.gradle script results in an unexpected error:
build.gradle:
def variable = new project.file('filename.ext')
The result:
c:\jdev\gradlebugs\20160112>gradle
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.
BUILD FAILED
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.)