google-java-format: Reflow long strings does not give same output
The following input
public class Test {
private String longString = "asdf asdf asdf asdf asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa";
}
Becomes
public class Test {
private String longString =
"asdf asdf asdf asdf"
+ " asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa";
}
Using google-java-format AOSP
When using the gradle task ./gradlew spotlessApply this becomes
public class Test {
private String longString =
"asdf asdf asdf asdf"
+ " asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa";
}
Gradle version: 8.10.2 Spotless version: 6.25.0 and 7.0.0.BETA4 (same result) Operating system: macOS 15.0.1
Spotless config:
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
java {
googleJavaFormat("1.24.0").aosp().reorderImports(true)
}
}
This is a bug in GJF, not Spotless. You'll have to report it there.
@nedtwigg Why is this a GJF and not a spotless bug? I would always expect spotless to do the same as GJF.
What GJF does to long strings also complies with the googla java style guide. https://google.github.io/styleguide/javaguide.html#s4.5.2-line-wrapping-indent. So I cant really put up a bug report about it there?
I would always expect spotless to do the same as GJF.
I would expect that too, and so far I don't have any evidence that it doesn't. Have you tried using GJF with AOSP on this same file?
Have you tried using GJF with AOSP on this same file?
@nedtwigg Sorry if it wasent clear from my issue, but that is exactly what I have done and shown in the snippets in the issue. First snippet is input, next is GJF with AOSP, last is Spotless with GJF and AOSP.