diff --git a/build.gradle b/build.gradle index 1e88c91662..cccf0d51a1 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,9 @@ buildscript { } apply plugin: 'com.android.application' +apply plugin: 'checkstyle' +apply plugin: 'pmd' +apply plugin: 'findbugs' ext { supportLibraryVersion = '23.4.0' @@ -41,12 +44,10 @@ dependencies { compile "com.android.support:cardview-v7:${supportLibraryVersion}" compile 'com.getbase:floatingactionbutton:1.10.1' - /// dependencies for local unit tests testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' - /// dependencies for instrumented tests // JUnit4 Rules androidTestCompile 'com.android.support.test:rules:0.5' @@ -73,6 +74,12 @@ tasks.withType(Test) { } android { + lintOptions { + abortOnError true + lintConfig file("${project.rootDir}/lint.xml") + htmlReport true + htmlOutput file("$project.buildDir/reports/lint/lint.html") + } compileSdkVersion 23 buildToolsVersion "23.0.3" @@ -100,14 +107,12 @@ android { assets.srcDirs = ['assets'] } - // move whole local unit tests structure as a whole from src/test/* to test/* test.setRoot('test') // move whole instrumented tests structure as a whole from src/androidTest/* to androidTest/* androidTest.setRoot('androidTest') - // Move the build types to build-types/ // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... // This moves them out of them default location under src//... which would @@ -131,4 +136,55 @@ android { exclude 'META-INF/LICENSE.txt' } + task checkstyle(type: Checkstyle) { + configFile = file("${rootProject.projectDir}/checkstyle.xml") + configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath + source 'src' + include '**/*.java' + exclude '**/gen/**' + classpath = files() + } + + task pmd(type: Pmd) { + ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml") + ignoreFailures = false + ruleSets = [] + + source 'src' + include '**/*.java' + exclude '**/gen/**' + + reports { + xml.enabled = false + html.enabled = true + xml { + destination "$project.buildDir/reports/pmd/pmd.xml" + } + html { + destination "$project.buildDir/reports/pmd/pmd.html" + } + } + } + + task findbugs(type: FindBugs) { + ignoreFailures = false + effort = "max" + reportLevel = "high" + classes = files("$project.buildDir/intermediates/classes") + excludeFilter = new File("${project.rootDir}/findbugs-filter.xml") + source 'src' + include '**/*.java' + exclude '**/gen/**' + + reports { + xml.enabled = false + html.enabled = true + html { + destination "$project.buildDir/reports/findbugs/findbugs.html" + } + } + classpath = files() + } + check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint' + } diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000000..e32ed1b7a1 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/findbugs-filter.xml b/findbugs-filter.xml new file mode 100644 index 0000000000..01ca48c7ee --- /dev/null +++ b/findbugs-filter.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pmd-ruleset.xml b/pmd-ruleset.xml new file mode 100644 index 0000000000..ce61196628 --- /dev/null +++ b/pmd-ruleset.xml @@ -0,0 +1,24 @@ + + + + The ruleset file checks code using rules defined below, new rules can always be added.The + pmd.html file contains the report which includes perceived coding issues + + .*/R.java + .*/gen/.* + + + + + + + + + + + + + \ No newline at end of file diff --git a/suppressions.xml b/suppressions.xml new file mode 100644 index 0000000000..a1dfee9e11 --- /dev/null +++ b/suppressions.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file