add checkStyle
@@ -34,9 +34,22 @@ task clean(type: Delete) {
delete rootProject.buildDir
}
-task checkStyle(type:Exec) {
- workingDir 'utils'
- commandLine './checkStyle.sh'
+task checkStyle(type:JavaExec) {
+ workingDir = "utils"
+ classpath = files("utils/google-java-format-1.7-all-deps.jar")
+ FileTree tree = fileTree('app/src/main/java') {
+ include '**/*.java'
+ }
+ args(["-n","--set-exit-if-changed"]) // -n prints filename if using wrong style
+ tree.each {args += it}
+ //color codes: "\u001B[33m" - yellow, "\u001B[32m" - green, "\u001B[0m" - reset (Unix)
+ doFirst {
+ println("You can fix the style of the files below (if any) with "
+ + "\u001B[33m" + "./gradlew applyStyle" + "\u001B[0m")
+ }
+ doLast { // will only execute on success (exitcode = 0)
+ println ("\u001B[32m" + " -> All java files follow the correct style." + "\u001B[0m")
+ }
}
task applyStyle(type:JavaExec) {
