After switching from eclipse projects to gradle projects I’m facing a problem concerning the
The junit tests of my projects run well under eclipse (in the original eclipse projects as well as in the eclipse projects generated by the gradle eclipse plugin) but fail under gradle. When I add some logging statement to those tests I can see that in the eclipse cases the Property
file.encoding is set to utf-8 while in the gradle case it reports windows-1252.
I managed to set the encoding for the compiler by adding
options.encoding = 'UTF-8' to
compileJava task but I found no similar solution for setting the encoding for the Testrunner.
The only workaround for now is setting the System-Environmentvariable GRADLE_OPTS=-Dfile.encoding=utf-8 , but I consider this a very ugly workaround since it might harm other builds on the Continuous integration environment.
There is also a similar question on Stackoverflow --> http://stackoverflow.com/questions/36263600/encoding-in-junit-gradle-vs-eclipse