How can I use the googleJavaFormat to make reflowLongStrings set to a max of 120 chars per line

1.8k Views Asked by At

I am using the Spotless plugin to format my Java code. However, when I am enabling the reflowLongStrings rule, it breaks lines to be no longer than 80 chars. Is it possible to change it to 120?

1

There are 1 best solutions below

0
On

Google java format is not configurable by design (have a look at this) so there is no way for configuring a custom max line width. What you can do is to configure spotless plugin to work with a custom eclipse jdt formatter. Here you can see how this is done in the spotless documentation.

For example, for gradle you would have:

spotless {
  java {
    eclipse().configFile('custom-config.xml')
  }
}

Instead of:

spotless {
  java {
    googleJavaFormat()
  }
}