Is setting "options.encoding" for Java/GroovyCompile-task of use?

I recently had an encoding problem with spock-reports. I am on Windows and the default encoding is “windows-1252”. My source code is “UTF-8” and so I did set

[compileJava, compileTestJava, compileGroovy, compileTestGroovy]*.options*.encoding = 'UTF-8'

and various variations of that like tasks.withType(JavaCompile). But it had no effect. The encoding of resulting spock-reports was incorrect wherever text from the source-code was extracted, like method names, which, as I was told, was taken from the compiler.

I discovered that setting JVM-option -Dfile.encoding=UTF8 did resolve this. and also discovered that if I did not set it manually, the default -Dfile.encoding=windows-1252 would be set. This setting seems to always override options.encoding from the JavaCompile/GroovyCompile-tasks, rendering this setting useless.

Am I correct with my assumption?

1 Like

I too have the same query. What happens if we don’t set this encoding? What is the default encoding used?