Following https://stackoverflow.com/a/48494454/3286489, I could now run the linting tasks (both in CLI and run in Android Studio) before compile my app.
My code as below.
android {
//....
lintOptions {
abortOnError true
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'compileDebugSources' || task.name == 'compileReleaseSources') {
task.dependsOn lint
task.mustRunAfter lint
}
}
However I dislike
task.name == 'compileDebugSources' || task.name == 'compileReleaseSources'
Is there a way to combine them and still get it working?