Clivern / wit-java

🗿Java Library For Wit.ai
https://wit.ai
Apache License 2.0
11 stars 2 forks source link

Enforce Google Java Style. #3

Closed Clivern closed 4 years ago

IEnoobong commented 4 years ago

Hi @Clivern Happy to take this up for #Hacktoberfest!

If I may ask, why AOSP style and not say Google Java Style guide, since this is not an Android project?

Same as https://github.com/Clivern/Racter/issues/13

Clivern commented 4 years ago

Sure you can take this over and https://github.com/Clivern/Racter/issues/13. I chosen the AOSP style because it is more readable. I kind of hate the google style with the 2 whitespace ident. But you can use it indeed for a PR.

I was thinking to use https://github.com/sherter/google-java-format-gradle-plugin. I used it somewhere else and works as expected.

Here's part of my build.gradle

plugins {
    id 'com.github.sherter.google-java-format' version '0.8'
}

googleJavaFormat {
  options style: 'AOSP'
}

It gives you two gradle tasks to format & verify

$ ./gradlew goJF --info
$ ./gradlew verGJF --info

or you can give https://github.com/diffplug/spotless a try

plugins {
    id 'com.diffplug.gradle.spotless' version '3.24.3'
}

spotless {
    java {
        licenseHeaderFile 'spotless.license.java'
        importOrder 'java'
    }
}
$ ./gradlew spotlessApply
$ ./gradlew spotlessJavaCheck
IEnoobong commented 4 years ago

Great, A number of folks have issues with the 2 whitespace indent too 😄. I'll begin with it from the when #Hacktoberfest begins using the google java format plugin