JavaExec task mangles UTF-8 output

Given enough occurrences of multi-byte UTF-8 characters in the output of a java task, Gradle will eventually mangle one of them, replacing each byte with 0xEFBFBD (replacement character). Some test code to reproduce this is available here: https://gist.github.com/raelik/3d04e5d942f01a6314af

Simply drop that UnicodeTest.java into an existing Gradle project that uses the java plugin, compile it, and then drop the unicode_test task into your build.gradle. Run the test code once through java on the command line and save the output (i.e. java -cp . UnicodeTest > cmd_output.txt), then run it through gradle (i.e. ./gradlew --quiet unicode_test 2>/dev/null > gradle_output.txt).

When you diff those files, you’ll see where gradle is dropping in the replacement characters.

1 Like

Thanks for sending this in. Managed to reproduce the problem, and created an issue: https://issues.gradle.org/browse/GRADLE-3329.

GRADLE-3329 has been fixed by https://github.com/gradle/gradle/commit/1746300a . This will be included in 3.2-rc-1 .