Code Monkey home page Code Monkey logo

sbt-java-formatter's Issues

Likely package should be `com.lightbend.sbt`

And as chatted on the eng meeting, such a thing could live under lightbend on github (or under sbt).

Shared ownership between our teams of this plugin would be perfect I thought @bantonsson, as we want to use it in Akka in any case.

Non-snapshot release of this plugin

Hey guys,

would it be possible to release non-snapshot version of this plugin? At work we are not able to use snapshots :( and i struggle finding a non-snapshot version post-bintray.

Thanks!

Make public + release

We'd like to use this in Akka, as people contributing Java code (for Akka HTTP) have settings all over the place, so we have spaces, tabs, 4 spaces, 2 spaces and everthing in between sometimes. Would want to just have a formatter there.

Release version 0.8.0

Release

java.lang.SecurityException: class "org.eclipse.jdt.core.compiler.InvalidInputException"'s signer information does not match signer information of other classes in the same package

I have this error randomly popping up. A week ago this worked fine. Removing the plugin also fixes the error.

java.lang.SecurityException: class "org.eclipse.jdt.core.compiler.InvalidInputException"'s signer information does not match signer information of other classes in the same package
	at java.lang.ClassLoader.checkCerts(ClassLoader.java:898)
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:761)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.eclipse.jdt.core.ToolFactory.createCodeFormatter(ToolFactory.java:173)
	at org.eclipse.jdt.core.ToolFactory.createCodeFormatter(ToolFactory.java:139)
	at com.lightbend.sbt.javaformatter.JavaFormatter$.apply(JavaFormatter.scala:67)
	at com.lightbend.sbt.JavaFormatterPlugin$$anonfun$toBeScopedSettings$2.apply(JavaFormatterPlugin.scala:88)
	at com.lightbend.sbt.JavaFormatterPlugin$$anonfun$toBeScopedSettings$2.apply(JavaFormatterPlugin.scala:76)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Formatting file does not override default settings

The formatting rules of the formatting-java.xml file are not used, no matter at which location it is specified:

  • /formatting-java.xml
  • project/formatting-java.xml

Example

sbt scripted test default-xml-file-location

Here, the formatting-java.xml has defined the indentation size of 4, but after compiling the source code it is formatted to an indentation size of 2.

<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>

The expected java file contains 2 spaces and the test is passing: https://github.com/typesafehub/sbt-java-formatter/blob/master/plugin/src/sbt-test/sbt-java-formatter/default-xml-file-location/src/main/java-expected/com/lightbend/BadFormatting.java

I've also tried it out with other projects and I was never able to format the source code based on my defined rules.

Conclusion

Currently, it is not possible to override the default formatting. If a formatting file is specified then the source code is formatted, but not by the rules of the formatting file.

Does not seem to reorder imports

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").

Add travis

I don't have admin rights in this repo so can't do it.
Admin me or please add travis :)

Fix credentials to bintray

@ktoso since this plugin is being released to your bintray repo (https://bintray.com/ktosopl/sbt-plugins/sbt-java-formatter) could you please update the credentials in .travis.yml file

env:
global:
# encrypt with: travis encrypt BINTRAY_USER=...
- secure: "mToe3N5fQj06rPdsgQxRUASQtZLlEHKKB45g+E+9vseJBTqXcoSM9C2KmQB4Xw2G2Nu7aBJrua36Cz+WF7J4SXUlh6IoY4RwjDjvLFzpLM0j4GCZlZAy0g3f5cOQpp87J03ujhleyEcuPNU1eqZUwSgyJyAiRfnG6wylGbgjPA9gy6HivSCBeVTrcAzQnT4iJbUHJQfWv2vrEwoqm+hqy/fEVAaoG+Pe7yBiA33gcg6ovt2mB5nycpkfPVvU2V/aTUv+bNlLVc1GqVkTVgq4t5qPL0J7rduaK6tp6gopGxdDapbxoUdMv7J+jrbg4jWsSSx6UlR6JclQKCCbatKi+nnXcKQnC33PN6dFWjyKTXB7nRUGlPJ16RyJA2NUi9Ip7rgZeVbAKNnShy5aG6XcnKrGRCkdATB1A+whQZ5sCpQ4kQ48swQZSA0QUIhknITKwC91ONsYiXGEkSjXRtz98aXSqcGG6nP4IjgNsHiBmr5i//xDFnYqNxKBV48Vvyv+QdrhBprrmgfe9vTQWdpalu1HZuAnax9JaUfTx8ujJ3sOZAQ+uQplK/kXo5NnyptcVdOoPu2ddFN5gtWbg7jGC/Iza6vGszFtOw2xoPT/BMetgTp5Ncv+ZNYY6jfRIlRX2BMYtH9HZU2fSSxs7YQs5TI5C/yMb/wXKDEcMPwet+Y="
# encrypt with: travis encrypt BINTRAY_PASS=...
- secure: "dLRZeB2nBuy7b6a6qXjiTeznGyKmH6Mbgi4OoAZMJAEt0WBQTcibjzC/5IBDpqzUVNMovUsfqypJzRhbTvPI70V/XjEUT987mOewK92hKISbSGkZ3wGgrMoskrVHvtro5QPoWqawy5sAGiI0qyyBj0d1m4hRB7pWpSwCLUbJIGcJRTBMGK6XzuKcqfuRwihr0dZFLQJnWc961+UykKvBF98MyMyaVvohRdundHik32J7gTGkPl3WINKk+LnUHjCXYEeZikphrxWbrS4M6PJmOkOpO7K/nariPzWYIifTDmxmF5YWa6DMzFsADlujObWotMwsDBTXh96b9Z+nYW+sG9GSYJIvW9i4dUPlPDDiDhXRdnYqo3adydwHwmmc/W6W6T2MCXXFQDYmFdE3Y4N9PrdrZGloLT0ZhPgLZ1lzEY6VoxuoEuj2uk6K3N/Z2aCUwls/lQhepvbEuWBZhtUP/fB+lBs85DGHl5uTFo2Mx9GDrwtoUA/Hgc3pIF3MSfd5dbulDYl4wKGDOXWhFn+LcTR6B2myZIxbuzvlJ65ABkiFLSv1JadsMp/tPb3xXYs4VdKijsZzOWYboDa0XM8Jp1yRnV3rQ42b0HTcDtyVkuenZ0MWVdi63tgZhN2F2/piWceYlpUQsTAAak4LC/9YJUPMjuaxMJY1yMX/IguBFp4="

to your Bintray username and API key from here?

This will enable automatic releases from Travis and I'll then be able to cut the 0.4.0 release.

Implement better config file location

Given:

subproject/formatting.xml
subproject/src/...      // should use `/subproject/formatting.xml`
src/...                 // should use `/formatting.xml`
formatting.xml 
other/src/...           // should use `/formatting.xml`

This way a sub project can be formatted using a different style if needed.

Release 0.6.1

Release 0.7.0

Release

Unable to use version 0.5.0

Unable to use version 0.5.0 but sbt javafmt works fine for 0.4.3

Error

14:27 $ sbt javafmt
[info] Loading global plugins from /Users/bharath/.sbt/1.0/plugins
[info] Loading settings for project bank-account-validation-build from plugins.sbt ...
[info] Loading project definition from /Users/bharath/Documents/devel/monorepo/mosaic/services/bank-account-validation/project
[info] Loading settings for project bank-account-validation from build.sbt ...
[info] Set current project to bank-account-validation (in build file:/Users/bharath/Documents/devel/monorepo/mosaic/services/bank-account-validation/)
[error] java.lang.NoClassDefFoundError: Could not initialize class com.lightbend.sbt.javaformatter.JavaFormatter$Analysis$
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.trackSourcesViaCache(JavaFormatter.scala:135)
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.cachedFormatSources(JavaFormatter.scala:109)
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.apply(JavaFormatter.scala:36)
[error]         at com.lightbend.sbt.JavaFormatterPlugin$.$anonfun$toBeScopedSettings$2(JavaFormatterPlugin.scala:69)
[error]         at com.lightbend.sbt.JavaFormatterPlugin$.$anonfun$toBeScopedSettings$2$adapted(JavaFormatterPlugin.scala:63)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error]         at sbt.std.Transform$$anon$4.work(System.scala:67)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.Execute.work(Execute.scala:278)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] java.lang.NoSuchMethodError: sbt.package$.singleFileJsonFormatter()Lsjsonnew/JsonFormat;
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$Analysis$.<init>(JavaFormatter.scala:67)
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$Analysis$.<clinit>(JavaFormatter.scala)
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.trackSourcesViaCache(JavaFormatter.scala:135)
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.cachedFormatSources(JavaFormatter.scala:109)
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.apply(JavaFormatter.scala:36)
[error]         at com.lightbend.sbt.JavaFormatterPlugin$.$anonfun$toBeScopedSettings$2(JavaFormatterPlugin.scala:69)
[error]         at com.lightbend.sbt.JavaFormatterPlugin$.$anonfun$toBeScopedSettings$2$adapted(JavaFormatterPlugin.scala:63)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error]         at sbt.std.Transform$$anon$4.work(System.scala:67)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.Execute.work(Execute.scala:278)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] java.lang.NoClassDefFoundError: Could not initialize class com.lightbend.sbt.javaformatter.JavaFormatter$Analysis$
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.trackSourcesViaCache(JavaFormatter.scala:135)
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.cachedFormatSources(JavaFormatter.scala:109)
[error]         at com.lightbend.sbt.javaformatter.JavaFormatter$.apply(JavaFormatter.scala:36)
[error]         at com.lightbend.sbt.JavaFormatterPlugin$.$anonfun$toBeScopedSettings$2(JavaFormatterPlugin.scala:69)
[error]         at com.lightbend.sbt.JavaFormatterPlugin$.$anonfun$toBeScopedSettings$2$adapted(JavaFormatterPlugin.scala:63)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error]         at sbt.std.Transform$$anon$4.work(System.scala:67)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.Execute.work(Execute.scala:278)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] (bank-account-validation-api / Compile / javafmt) java.lang.NoClassDefFoundError: Could not initialize class com.lightbend.sbt.javaformatter.JavaFormatter$Analysis$
[error] (bank-account-validation-impl / Compile / javafmt) java.lang.NoSuchMethodError: sbt.package$.singleFileJsonFormatter()Lsjsonnew/JsonFormat;
[error] (Compile / javafmt) java.lang.NoClassDefFoundError: Could not initialize class com.lightbend.sbt.javaformatter.JavaFormatter$Analysis$
[error] Total time: 0 s, completed 14 Jan, 2020 2:27:52 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.