Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS independent call to applyStyle #313

Merged
merged 8 commits into from Dec 12, 2022
34 changes: 31 additions & 3 deletions android/build.gradle
Expand Up @@ -34,12 +34,40 @@ task clean(type: Delete) {
delete rootProject.buildDir
}

task checkStyle(type:Exec) {
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 checkStyleUnix(type:Exec) {
workingDir 'utils'
commandLine './checkStyle.sh'
}

task applyStyle(type:Exec) {
task applyStyle(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("-r") // replace cmd, means write changes back to source file
tree.each {args += it}
}

task applyStyleUnix(type:Exec) {
workingDir 'utils'
commandLine './applyStyle.sh'
}
}