sbt / sbt-java-formatter

An sbt plugin for formating Java code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not seem to reorder imports

nat-henderson opened this issue · comments

Hi,

I'm seeing that this plugin does not reorder imports as required by the google java style guide 3.3. For instance, if I make the following change to get the imports out of order

 import static play.test.Helpers.contentAsString;
 
 import akka.actor.ActorSystem;
-import controllers.AsyncController;
 import controllers.CountController;
+import controllers.AsyncController;
 import java.util.concurrent.CompletionStage;
 import org.junit.Test;
 import play.mvc.Result;

and run sbt javafmtAll, then git diff, I still see the diff (which is intentionally erroneous).

 import static play.test.Helpers.contentAsString;
 
 import akka.actor.ActorSystem;
-import controllers.AsyncController;
 import controllers.CountController;
+import controllers.AsyncController;
 import java.util.concurrent.CompletionStage;
 import org.junit.Test;
 import play.mvc.Result;

My plugins.sbt file contains addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.6.0").

This plugin relies on Google Java Formatter 1.7 which does not touch the order of imports.

You may be able of override it to a later version. See #102

Got it - I decided to build my own solution which anyone who finds this issue later can see here:

https://github.com/seattle-uat/universal-application-tool/pull/27/files

See bin/fmt and formatter.Dockerfile.