-
Notifications
You must be signed in to change notification settings - Fork 485
Description
I'm using formatAnnotations()
together with googleJavaFormat()
and introducing the former also brought surprising changes. Type annotations on class and method declarations are affected:
-@Value
-@Jacksonized
+@Value @Jacksonized
@Builder
public class Example {
@Bean
- @Qualifier("example")
- RestTemplate example() {
+ @Qualifier("example") RestTemplate example() {
However, Google's Java Style Guide, section "4.8.5 Annotations" says that
Annotations applying to a class appear immediately after the documentation block, and each annotation is listed on a line of its own (that is, one annotation per line).
and the same applies to method and constructor annotations, without mentioning any exception for type annotations.
Moreover, the claim that "Type annotations should be on the same line as the type that they qualify." in Spotless Gradle plugin's README doesn't cite any source.
So which of these formatters is right?
My Spotless configuration for Java:
spotless {
encoding("UTF-8")
java {
target("src/*/java/**/*.java")
targetExclude("**/build/")
importOrder()
removeUnusedImports()
googleJavaFormat()
formatAnnotations()
}
}
Spotless 6.11.0 with Gradle 7.5.1