Merge pull request #3282 from wb9688/checkstyle

Check code style with Checkstyle
This commit is contained in:
Tobias Groza 2020-04-03 17:10:07 +02:00 committed by GitHub
commit bbe617923c
254 changed files with 12120 additions and 8835 deletions

View file

@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'checkstyle'
android {
compileSdkVersion 28
@ -82,11 +83,53 @@ ext {
icepickLibVersion = '3.2.0'
stethoLibVersion = '1.5.0'
markwonVersion = '4.2.1'
checkstyleVersion = '8.31'
}
checkstyle {
configFile rootProject.file('checkstyle.xml')
ignoreFailures false
showViolations true
toolVersion = "${checkstyleVersion}"
}
task runCheckstyle(type: Checkstyle) {
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
exclude 'main/java/us/shandian/giga/**'
// empty classpath
classpath = files()
showViolations true
reports {
xml.enabled true
html.enabled true
}
}
tasks.withType(Checkstyle).each {
checkstyleTask -> checkstyleTask.doLast {
reports.all { report ->
def outputFile = report.destination
if (outputFile.exists() && outputFile.text.contains("severity=\"error\"")) {
throw new GradleException("There were checkstyle errors! For more info check $outputFile")
}
}
}
}
preBuild.dependsOn runCheckstyle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation "android.arch.persistence.room:testing:1.1.1"
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
@ -165,4 +208,4 @@ static String getGitWorkingBranch() {
// git was not found
return ""
}
}
}