Spring-boot: Configure UTF-8 encoding on Java Format's tasks

Created on 27 Jan 2020  Â·  6Comments  Â·  Source: spring-projects/spring-boot

When gradle format is run on entire repository, 3 files are updated. However, this only messes up non-ascii strings. For reference, see https://github.com/kedar-joshi/spring-boot/commit/bc30fc26f21a4aaa4b51ab0a092c981478be438e.

Running .\gradlew format produces following output -

D:\OSS\spring-boot>.\gradlew format               

BUILD SUCCESSFUL in 18s
211 actionable tasks: 211 executed

.. but it also modifies three files where the only change is in non-ascii strings. Ideally, formatter should not change the contents of Java strings.

Environment
JDK : Oracle JDK 8
OS : Windows 10 Pro (64 Bit)
Locale : en_IN
Charset : Latin-1 (ISO-8859-1).

task

Most helpful comment

Thanks. That sounds like the problem then. I've just pushed a change that should hopefully fix it.

All 6 comments

@kedar-joshi I just ran this command on master and no file was changed:

➜  spring-boot/master git:(master) ./gradlew format

BUILD SUCCESSFUL in 5s
211 actionable tasks: 211 executed

Can you be a bit more specific?

Can you be a bit more specific?

When I run .\gradlew format I also get following output -

D:\OSS\spring-boot>.\gradlew format               

BUILD SUCCESSFUL in 18s
211 actionable tasks: 211 executed

.. but running this task also modifies three files with only change in non-ascii strings.

I suspect it's because we're not setting the encoding and it's picking up the default from the shell. @kedar-joshi what's the default locale and charset on your system?

@kedar-joshi what's the default locale and charset on your system?

My locale is en_IN and charset is Latin-1 (ISO-8859-1).

Thanks. That sounds like the problem then. I've just pushed a change that should hopefully fix it.

Yes, the fix worked perfectly. Thank you.

Was this page helpful?
0 / 5 - 0 ratings