Okay after a little of investigation I realized what you were trying to do with your patch:
def defaultEncoding = 'UTF-8'
tasks.withType(AbstractCompile)*.options*.encoding = defaultEncoding
tasks.withType(GroovyCompile)*.groovyOptions*.encoding = defaultEncoding
AbstractCompile is the parent of JavaCompile, GroovyCompile and other compile tasks, and so this code snippet iterates through this compilation syntax to try to enforce the character encoding on all compile tasks.
GroovyCompile has an additional field for GroovyCompileOptions which extends from AbstractCompileOptions. But CompileOptions (java) also extends from AbstractCompileOptions. So the two separate classes need to set the encoding.
Now, I think the following errors are present in the code:
- The default encoding is already UTF-8, not sure that we need to enforce it unless something is wrong in your default encoding options on the OS?
- GroovyCompileOptions setting for encoding is not needed because we aren't running any gradle plugins or compile tasks.
There are two code snippets which you can try, and please tell me if either one works for you. I am listing the two so that if the first one does not work, then we know the problem is OS related in config settings:
options.encoding = System.getProperty('file.encoding')
options.encoding = 'UTF-8'