Repository navigation
Set max line length for google formatter #1563
Description
Activity
- changed the title
[-]No max line length for google formatter[/-][+]Set max line length for google formatter[/+]on Feb 8, 2023 If
gjfwas converted to a compile-only integration, as inThen this would be pretty easy to implement. PRs welcome.
I've converted GJF to a compile-only integration. To reduce complexity, I would suggest that we'll require GJF of at least version
1.8(which was released back in May 2020). Before that, we would have two API changes that would require to have specific compile-only variants. Since that version is years old, I don't think any spotless user would have an issue with that requirement.After having converted GJF to a compile-only dependency, I've tried to introduce a configuration for the max-line-length. GJF however has taken every measure, for this property to not be changeable, as can be seen here:
They've decided to make this a
public static final intthat gets assigned on declaration. So even with (ugly) reflection, the value cannot be changed, since the compiler does inline this value wherever it is used within the gjf lib.It was possible to change this value up to GJF Release
1.7by doing some ugly wrapping of theJavaFormatterOptionsclass at this location:This is, ultimately, what the aformentioned maven-plugin does:
https://github.com/talios/googleformatter-maven-plugin/blob/2034133fe14f0ee928c6942cd037f1fbd52f0abd/src/main/java/com/theoryinpractise/googleformatter/GoogleFormatterMojo.java#L142-L146This approach, however, is no longer feasible, as it is only working for GJF Versions ≤
1.7.TL;DR: it is not possible to make GFJ's
max-line-lengthproperty configurable. Which means this feature request cannot be satisfied.@nedtwigg Given the above, should I create a PR to merge the transition of GJF to a compile-only dependency, or would you rather keep it "the old way" using reflection?
Reacted by Jonathan Bluett-DuncanA GJF conversion to compile-only which drops support for pre-1.8 is very welcome, thanks @simschla!
I apologize for sending a wild goose-chase regarding max-line-length. I'm going to close this issue since it appears impossible to implement.
I apologize for sending a wild goose-chase regarding max-line-length. I'm going to close this issue since it appears impossible to implement.
No worries, as it turns out, there is always something to be learned, even if the result is finding out, that something is not possible... 🤔
I've created #1630 to convert gjf to a compile-only dependency.
max-line-length
Hello
How configure it on maven?<googleJavaFormat> <version>1.11.0</version> <style>AOSP</style> </googleJavaFormat>???
@pks-1981 As of now, this setting is not possible due to design decisions on Google's side.
Cant set max line length as in https://github.com/talios/googleformatter-maven-plugin
Is any solutions for this exist? Other formatters with googlse style or else?