Skip to content

Spotless with Eclipse Import Order has different ordering than Eclipse Formatter #522

Closed
@thespags

Description

@thespags

If you are submitting a bug, please include the following:

  • summary of problem
    Spotless with eclipse formatter orders static imports differently than eclipse or eclipse plugin in Intellij
  • gradle or maven version
    mvn 3.3.3
  • spotless version
    1.27.0
  • operating system and version
    Description: Ubuntu 16.04.6 LTS
  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
                   <java>
                       <importOrder>
                           <file>/style/myTeam.importorder</file>
                       </importOrder>
                   </java>
               </configuration>

with order

#Organize Import Order
#Fri Jun 28 15:00:43 PDT 2019
4=com.myTeam
3=java
2=javax
1=
0=\#
  • copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace
    N/A

If you're just submitting a feature request or question, no need for the above.

EclipseFormatter issues
krasa/EclipseCodeFormatter#200
krasa/EclipseCodeFormatter#105

Write

package somePackage;

import static somePackage.Foo.SomeEnum.Bar;
import static somePackage.Foo.SomeZClass;
import static somePackage.Foo.SomeZClass.m;

import java.util.function.Supplier;

// Use as a type argument to be a static import.
public class Foo implements Supplier<SomeZClass> {

    public void someMethod() {
        SomeEnum e = Bar;
        m(); // call m with a static import
    }

    @Override
    public SomeZClass get() {
        return null;
    }

    public enum SomeEnum {
        Bar
    }

    // Add Z this should be sorted after SomeEnum
    public static class SomeZClass {
        static void m() {}
    }
}

Eclipse Plugin will order imports:

import static somePackage.Foo.SomeZClass;
import static somePackage.Foo.SomeEnum.Bar;
import static somePackage.Foo.SomeZClass.m;

Eclipse will order imports:

import static somePackage.Foo.SomeEnum.Bar;
import static somePackage.Foo.SomeZClass.m;

import java.util.function.Supplier;

import somePackage.Foo.SomeZClass;

and spotless will order imports


import static somePackage.Foo.SomeEnum.Bar;
import static somePackage.Foo.SomeZClass;
import static somePackage.Foo.SomeZClass.m;

import java.util.function.Supplier;

Spotless using Eclipse format rules should have the same behavior as Eclipse

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions