Contrary to the formatter within the Eclipse IDE (which sorts Java class members and imports alphabetically), the eclipse formatter within Spotless sorts Java class members and imports lexicographically (!?!) — here it is my configuration:
<eclipse>
<file>${project.basedir}/config/eclipse/java-style.xml</file>
<sortMembersEnabled>true</sortMembersEnabled>
<!-- Optional: Specify the sort order of the member categories. (default: T,SF,SI,SM,F,I,C,M)
SF,SI,SM,F,I,C,M,T = Static Fields, Static Initializers, Static Methods, Fields, Initializers, Constructors, Methods, (Nested) Types -->
<sortMembersOrder>T,SF,SI,SM,F,I,C,M</sortMembersOrder>
<sortMembersVisibilityOrderEnabled>true</sortMembersVisibilityOrderEnabled>
<!-- Optional: Specify the ordering of members of the same category by the visibility within the category (default: B,V,R,D).
B,R,D,V = Public, Protected, Package, Private -->
<sortMembersVisibilityOrder>B,R,D,V</sortMembersVisibilityOrder>
</eclipse>
Feeding Eclipse IDE-formatted source code to spotless-maven-plugin, the resulting source code differs just in its sorting — for example:
public static Optional<StackFrame> callerFrame() {
. . .
}
public static Object callOrThrow(. . .) {
. . .
}
public static Object callOrThrow(. . .) {
. . .
}
public static Optional<StackFrame> callerFrame() {
. . .
}
In case of homonymous methods, lexicographic sorting is applied to the parameter type names:
public static String transform(char[] value) {
. . .
}
public static String transform(String value) {
. . .
}
public static String transform(String value) {
. . .
}
public static String transform(char[] value) {
. . .
}
The imports are also affected by the same problem:
import static org.myexample.util.MyClass.anotherFunction;
import static org.myexample.util.MyClass.NestedType.myFunction;
import static org.myexample.util.MyClass.NestedType.myFunction;
import static org.myexample.util.MyClass.anotherFunction;
Why such an inconsistency, considering that both the formatters are based on JDT?
(Have I overlooked any configuration option?)
Contrary to the formatter within the Eclipse IDE (which sorts Java class members and imports alphabetically), the
eclipseformatter within Spotless sorts Java class members and imports lexicographically (!?!) — here it is my configuration:Feeding Eclipse IDE-formatted source code to spotless-maven-plugin, the resulting source code differs just in its sorting — for example:
In case of homonymous methods, lexicographic sorting is applied to the parameter type names:
The imports are also affected by the same problem:
Why such an inconsistency, considering that both the formatters are based on JDT?
(Have I overlooked any configuration option?)